1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Kim Wittenburg 15062dfb27 Archive Project
2017-07-25 17:21:13 +02:00

85 lines
6.3 KiB
Objective-C
Executable File

//
// NYTUpdater.h
// Notifications for YouTube
//
// Created by Kim Wittenburg on 09.07.13.
// Copyright (c) 2013 Kim Wittenburg. All rights reserved.
//
/* Defines a key in the userInfo dictionary of an NSUserNotification that can be used to receive an URL (in the form of a string) that represents the video the notification was sent for.
*/
extern NSString * const NYTUserNotificationURLKey;
@class NYTUser;
/* The NYTUpdater class is the core class to refresh the upload feeds of the channels defined in the NYTSubscriptionManager singletone class. This class is also responsible for generating appropriate user notifications and presenting them to the user.
If you want to create you own subclass of update manager you must make sure that it's instance is created before the default one gets created.
*/
@interface NYTUpdateManager : NSObject
#pragma mark *** Obtaining the Shared Instance ***
/* Use this method to obtain the shared instance. The init message will only be sent once. Any further sharedUpdater or init messages will just return the shared instance.
*/
+ (NYTUpdateManager *)sharedManager;
- (id)init;
#pragma mark *** Refreshing Feeds ***
/* A KVO compilant property telling you wether there is currently an update in progress or not.
*/
@property (readonly) BOOL refreshing;
/* Returns wether a refresh is currently possible. Always query this status before performing a refresh because otherwise your app might crash if there is no user currently logged in.
*/
- (BOOL)canRefresh;
/* Refreshes the feeds in the background and notifies the handler about any errors occured. If no error occured the handler is NOT invoked. If you want to know when the refresh process finished you can observe on the refreshing property for changes using KVO.
If the update manager is already refreshing this method does nothing and returns immediately. The error handler is NOT invoked.
You can specify a notify flag. If this flag is set to YES the update manger delivers a user notification for each new video. You may want to specify NO to set the current videos as the 'root' position, that is that these videos are 'known'. This is automatically done when the login changes (otherwise there could be a notification for each of the 98 videos in the feed).
*/
- (void)refreshFeedsWithErrorHandler:(void (^)(NSError *))handler notify:(BOOL)flag;
#pragma mark *** Notifications ***
/* Note to Notification restrictions: Notifications may also be restricted by the user-defined rules. The rules are stored in the user defaults for the key "Rules". For information on the format of rules see NYTRulesWindowController.
*/
/* When refreshing feeds notifications will only be sent for feeds that are in the specified date range from now to a date that is offset to the past by this value.
Specify 0 to not prevent notifications by time. Negative values will be evaluated as 0.
*/
@property NSTimeInterval maximumVideoAge;
/* If set to YES multiple video uploads will be coalesced into a single notification in the form of 'xy new videos' - 'abc, def, ghi and 42 more uploaded new videos'. The NYTUserNotificationURLKey value will not be a video URL but to an URL to the user's subscription video list on YouTube.
*/
@property BOOL coalescesNotifications;
#pragma mark *** Auto Refresh ***
/* Enabling and disabling auto refresh: You can turn on and off auto refresh permanently. This means that the auto refresh timer will be stopped and not be started again until auto refresh is re-enabled. While auto refresh is disabled pausing and resuming is still usable. Enabling auto refresh while it is paused will not start auto refresh. Auto refresh will be actually started when the same number of resume messages as pause messages were sent. You can still modify and query the refresh interval while auto refresh is disabled.
While auto refresh is running the timer is also running and firing events. But if canRefresh returns NO auto refresh will not perform a refresh but just do nothing. (It will not stop the timer.)
*/
@property (getter = isAutoRefreshEnabled) BOOL autoRefreshEnabled;
/* Restarts auto refresh. If auto refresh is currently disabled this method has no effect. Use this method if you want the next auto refresh update to be fired in the amount of seconds specified by the auto refresh interval.
*/
- (void)restartAutoRefresh;
/* These methods pause and resume the auto refresh timer. The autoRefreshRunning property tells you wether the auto refresh timer is currently running (which means is will be set to NO if auto refresh is paused).
Pausing and resuming auto refresh can be useful if you program enters a critical section during whose execution there should be no refresh (for example during modifying the update settings). Calls of pauseAutoRefreshing and resumeAutoRefreshing can be nested. Every pause message must have a corresponding resume message and vice versa. Auto refreshing will not be resumed until the same amount of resume messages were sent as pause messages were sent before.
Pausing and resuming auto refresh is used by the update manager at several times (for example while the login/logout process is running). Do not suggest wether auto refreshing is currently running or paused based on your code. Always query the current staus by sending a isAutoRefreshRunning message before.
*/
@property (readonly, getter = isAutoRefreshRunning) BOOL autoRefreshRunning;
- (void)pauseAutoRefreshing;
- (void)resumeAutoRefreshing;
/* Performs an auto refresh. Although this method returns immediately it may not immediately refresh. If this method is invoked while auto refresh is "sleeping" the next time auto refresh will get actually started (as determined by isAutoRefreshRunning) it will trigger a refresh immediately. If auto refresh gets disabled after this method gets invoked or already is disabled by now nothing will happen.
*/
- (void)performAutoRefresh:(id)sender;
/* The time interval used by auto refresh to refresh the feeds. Specified in seconds. If you change this property the elapsed time is transfered to the new interval. If the new interval is smaller than the elapsed time auto refresh refreshes immediately. Specify 0 to refresh as often as possible (may be very inefficient since Auto Refresh is constructed to refresh over time.
*/
@property (nonatomic) NSTimeInterval autoRefreshInterval;
@end