package rsctrl.files;

import "core.proto";

///////////////////////////////////////////////////////////////
// List Transfers.
// Control Transfers.
//
// TODO:
// Share Directories.
///////////////////////////////////////////////////////////////

enum RequestMsgIds {
    MsgId_RequestTransferList 		= 1;
    MsgId_RequestControlDownload   	= 2;
    MsgId_RequestShareDirList		= 3;
}

enum ResponseMsgIds {
    MsgId_ResponseTransferList  	= 1;
    MsgId_ResponseControlDownload  	= 2;
    MsgId_ResponseShareDirList		= 3;
}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

// Building Blocks

enum Direction {
    DIRECTION_UPLOAD    = 1;
    DIRECTION_DOWNLOAD  = 2;
}


enum TransferState {
    TRANSFER_FAILED   		= 1;
    TRANSFER_OKAY    		= 2;
    TRANSFER_PAUSED    		= 3;
    TRANSFER_QUEUED    		= 4;
    TRANSFER_WAITING  	 	= 5;
    TRANSFER_DOWNLOADING    	= 6;
    TRANSFER_CHECKING_HASH    	= 7;
    TRANSFER_COMPLETE 	 	= 8;
}


message FileTransfer {

  required rsctrl.core.File file 	= 1;
  required Direction direction		= 2;
  required float fraction		= 3;
  required float rate_kBs		= 4;
  required TransferState state		= 5;
}

///////////////////////////////////////////////////////////////
// Transfer List.

// REQUEST: RequestTransferList
message RequestTransferList {
  required Direction direction = 1;
}

// RESPONSE: ResponseTransferList
message ResponseTransferList {

  required rsctrl.core.Status status = 1;
  repeated FileTransfer transfers = 2;

}

///////////////////////////////////////////////////////////////
// Download.

// REQUEST: RequestControlDownload
// START requires name, hash & size.
// other actions only require file hash.
message RequestControlDownload {

  enum Action {
    ACTION_START    = 1; 	// start download.
    ACTION_CONTINUE = 2; 	// move to top of queue.
    ACTION_WAIT     = 3;	// send to bottom of queue.
    ACTION_PAUSE    = 4; 	// hold indefinitely. 
    ACTION_RESTART  = 5; 	// end pause, restart download.
    ACTION_CHECK    = 6; 	// force check.
    ACTION_CANCEL   = 7; 	// remove permenantly.
  }

  required rsctrl.core.File file 	= 1;
  required Action action 		= 2;

}

// RESPONSE: ResponseControlDownload
message ResponseControlDownload {
  required rsctrl.core.Status status = 1;
}


///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
// SHARED FILES

// REQUEST: RequestShareDirList
message RequestShareDirList {
  required string ssl_id = 1; 
  required string path = 2;
}


// RESPONSE: ResponseShareDirList
message ResponseShareDirList {
  required rsctrl.core.Status status = 1;

  enum ListType {
    DIRQUERY_ROOT 	= 1; 	// the query refers to root.
    DIRQUERY_PERSON 	= 2; 	// the query refers to person
    DIRQUERY_FILE 	= 3; 	// the query refers to a file.
    DIRQUERY_DIR 	= 4; 	// move to top of queue.
  }

  required string ssl_id 		= 2; 
  required string path 			= 3;
  required ListType list_type 		= 4;
  repeated rsctrl.core.File files 	= 5;
}


//// REQUEST: RequestChangeShares
//
//// REQUEST: RequestLiCloseSearch
//// REQUEST: RequestCloseSearch
//



///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

