//
//  VCDataReceiverDownloader.h
//  Vacuum
//
//  Created by Lukáš Foldýna on 06.08.13.
//  Copyright (c) 2013 Arat. All rights reserved.
//

#import "VCTransferableItem.h"
#import "VCTransferProtocol.h"
#import "VCDataReceiver.h"
#import "GCDAsyncSocket.h"


@interface VCDataReceiverDownloader : NSObject

- (instancetype)initWithSocket:(GCDAsyncSocket *)socket receiver:(VCDataReceiver *)receiver;

@property (nonatomic, weak) VCDataReceiver *receiver;

@property (nonatomic, strong) VCService *sender;
@property (nonatomic, strong) NSString *senderPushNotificationToken;

@property (nonatomic, assign) VCDataReceiverState state;
@property (nonatomic, strong) GCDAsyncSocket *readingSocket;

@property (nonatomic, strong) NSFileHandle *currentReceivingFileWriteHandle;
@property (nonatomic, strong) NSMutableData *transferedData;
@property (nonatomic, assign) unsigned long long contentLength;
@property (nonatomic, assign) unsigned long long amountTransfered;

@property (nonatomic, strong) NSArray *receivedFiles;
@property (nonatomic, strong) VCTransferProtocol *transferProtocol;

@property (nonatomic, assign) NSUInteger currentReceivingFileIndex;

/** Tells that receiwer is waiting for 'allowFileTransfer' or 'denyFileTransfer' messages to be send to decide next step of file transfer */
@property (nonatomic, assign) BOOL isWaitingForTransferApprovalOrDenial;

/** Tells that receiwer is waiting for 'allowNoticationToken' or 'denyNotificationToken' messages to be send to decide next step of transfer */
@property (nonatomic, assign) BOOL isWaitingForNotificationTokenApprovalOrDenial;

@property (nonatomic, assign, readonly) BOOL isWaitingForApprovalOrDenial; // isWaitingForTransferApprovalOrDenial || isWaitingForNotificationTokenApprovalOrDenial

- (void)allowDownload;
- (void)denyDownload;

- (void)allowNotificationToken;
- (void)denyNotificationToken;

- (void)disconnect;

@end
