/**
 * VCDevicesSender.h: Vacuum
 * Created by Jiří Urbášek on 9/29/12.
 *
 * Copyright (c) 2012, Arat. All rights reserved.
 *
 * This source code can be used only for purposes specified
 * by the given license contract signed by the rightful deputy of Arat.
 * This source code can be used only by the owner of the license.
 *
 * Any disputes arising in respect of this agreement (license) shall be brought
 * before the Municipal Court of Prague.
 */

#import <Foundation/Foundation.h>
#import "VCService.h"
#import "VCTransferableItem.h"


@protocol VCDataSenderDelegate;

@interface VCDataSender : NSObject

@property (nonatomic, weak) id<VCDataSenderDelegate> delegate;
@property (nonatomic, assign, readonly) BOOL isSendingData; // if it sending any data
@property (nonatomic, strong, readonly) VCService *service; // connected service

/**
 * Sends one or more files to a service
 * @param files array of object confirming to VCTransferableFile protocol
 * @param service to which files will be sent
 */
- (void)sendFiles:(NSArray<id<VCTransferableItem>> *)files service:(VCService *)service;
@property (nonatomic, strong, readonly) NSArray<id<VCTransferableItem>> *filesToSend;

/**
 * Request notification token from service
 */
- (void)requestNotificationTokenFromService:(VCService *)service;

/** Stop transfer */
- (void)cancel;

@end


@protocol VCDataSenderDelegate <NSObject>

@required
- (void)senderDidFinishSendingAllFiles:(VCDataSender *)sender;
- (void)sender:(VCDataSender *)sender didFailWithError:(NSError *)error;

@optional
- (void)senderDidStartSending:(VCDataSender *)sender;
- (void)senderDidReceiveCancelationByOtherSide:(VCDataSender *)sender;
- (void)sender:(VCDataSender *)sender didFinishSendingFile:(id<VCTransferableItem>)file;
- (void)sender:(VCDataSender *)sender didSendPartOfFile:(id<VCTransferableItem>)file currentLength:(unsigned long long)currentLength;
- (void)sender:(VCDataSender *)sender didReceiveNotificationToken:(NSString *)token deviceID:(NSString *)deviceID applicationType:(NSString *)applicationType;

@end


#define kVCErrorCodeTransferCanceled     501
#define kVCErrorCodeCanceledByOtherSide  504
