Updated new_filesender function in Messenger.c

This commit is contained in:
irungentoo 2015-03-09 19:21:51 -04:00
parent 4c4ffb7409
commit 576e5ee703
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 22 additions and 9 deletions

View File

@ -1022,14 +1022,21 @@ static int file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t fi
/* Send a file send request.
* Maximum filename length is 255 bytes.
* return file number on success
* return -1 on failure
* return -1 if friend not found.
* return -2 if filename too big.
* return -3 if no more file sending slots left.
* return -4 if could not send packet (friend offline).
*
*/
int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename,
uint16_t filename_length)
long int new_filesender(const Messenger *m, int32_t friendnumber, uint32_t file_type, uint64_t filesize,
const uint8_t *filename, uint16_t filename_length)
{
if (friend_not_valid(m, friendnumber))
return -1;
if (filename_length > MAX_FILENAME_LENGTH)
return -2;
uint32_t i;
for (i = 0; i < MAX_CONCURRENT_FILE_PIPES; ++i) {
@ -1038,14 +1045,15 @@ int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize,
}
if (i == MAX_CONCURRENT_FILE_PIPES)
return -1;
return -3;
if (file_sendrequest(m, friendnumber, i, 0, filesize, filename, filename_length) == 0)
return -1;
if (file_sendrequest(m, friendnumber, i, file_type, filesize, filename, filename_length) == 0)
return -4;
m->friendlist[friendnumber].file_sending[i].status = FILESTATUS_NOT_ACCEPTED;
m->friendlist[friendnumber].file_sending[i].size = filesize;
m->friendlist[friendnumber].file_sending[i].transferred = 0;
m->friendlist[friendnumber].file_sending[i].type = file_type;
return i;
}

View File

@ -129,6 +129,7 @@ struct File_Transfers {
uint64_t size;
uint64_t transferred;
uint8_t status; /* 0 == no transfer, 1 = not accepted, 2 = paused by the other, 3 = transferring, 4 = broken, 5 = paused by us */
unsigned int type;
};
enum {
FILESTATUS_NONE,
@ -579,10 +580,14 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, uint32_t, u
/* Send a file send request.
* Maximum filename length is 255 bytes.
* return file number on success
* return -1 on failure
* return -1 if friend not found.
* return -2 if filename too big.
* return -3 if no more file sending slots left.
* return -4 if could not send packet (friend offline).
*
*/
int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename,
uint16_t filename_length);
long int new_filesender(const Messenger *m, int32_t friendnumber, uint32_t file_type, uint64_t filesize,
const uint8_t *filename, uint16_t filename_length);
/* Send a file control request.
* send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.