@@ -17,23 +17,27 @@ #import "OFObject.h" @class OFDate; @class OFTimer; + +#define BPS_WINDOW_SIZE 10 @interface ProgressBar: OFObject { - intmax_t _received, _lastReceived, _length, _resumedFrom; + unsigned long long _received, _lastReceived, _length, _resumedFrom; OFDate *_startDate, *_lastReceivedDate; OFTimer *_drawTimer, *_BPSTimer; bool _stopped; float _BPS; double _ETA; + float _BPSWindow[BPS_WINDOW_SIZE]; + size_t _BPSWindowIndex, _BPSWindowLength; } -- (instancetype)initWithLength: (intmax_t)length - resumedFrom: (intmax_t)resumedFrom; -- (void)setReceived: (intmax_t)received; +- (instancetype)initWithLength: (unsigned long long)length + resumedFrom: (unsigned long long)resumedFrom; +- (void)setReceived: (unsigned long long)received; - (void)draw; - (void)calculateBPSAndETA; - (void)stop; @end