summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-03-09 19:21:51 -0400
committerirungentoo <irungentoo@gmail.com>2015-03-09 19:21:51 -0400
commit576e5ee703a3740c558a6e742cc2bcfce5feafbf (patch)
treec3a033e698651d093a8e67892413c7d00ec365ab
parent4c4ffb74093037ab6cd02d310a07b73022becf83 (diff)
Updated new_filesender function in Messenger.c
-rw-r--r--toxcore/Messenger.c20
-rw-r--r--toxcore/Messenger.h11
2 files changed, 22 insertions, 9 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 251d00d2..ee76b103 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -1022,14 +1022,21 @@ static int file_sendrequest(const Messenger *m, int32_t friendnumber, uint8_t fi
1022/* Send a file send request. 1022/* Send a file send request.
1023 * Maximum filename length is 255 bytes. 1023 * Maximum filename length is 255 bytes.
1024 * return file number on success 1024 * return file number on success
1025 * return -1 on failure 1025 * return -1 if friend not found.
1026 * return -2 if filename too big.
1027 * return -3 if no more file sending slots left.
1028 * return -4 if could not send packet (friend offline).
1029 *
1026 */ 1030 */
1027int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, 1031long int new_filesender(const Messenger *m, int32_t friendnumber, uint32_t file_type, uint64_t filesize,
1028 uint16_t filename_length) 1032 const uint8_t *filename, uint16_t filename_length)
1029{ 1033{
1030 if (friend_not_valid(m, friendnumber)) 1034 if (friend_not_valid(m, friendnumber))
1031 return -1; 1035 return -1;
1032 1036
1037 if (filename_length > MAX_FILENAME_LENGTH)
1038 return -2;
1039
1033 uint32_t i; 1040 uint32_t i;
1034 1041
1035 for (i = 0; i < MAX_CONCURRENT_FILE_PIPES; ++i) { 1042 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,
1038 } 1045 }
1039 1046
1040 if (i == MAX_CONCURRENT_FILE_PIPES) 1047 if (i == MAX_CONCURRENT_FILE_PIPES)
1041 return -1; 1048 return -3;
1042 1049
1043 if (file_sendrequest(m, friendnumber, i, 0, filesize, filename, filename_length) == 0) 1050 if (file_sendrequest(m, friendnumber, i, file_type, filesize, filename, filename_length) == 0)
1044 return -1; 1051 return -4;
1045 1052
1046 m->friendlist[friendnumber].file_sending[i].status = FILESTATUS_NOT_ACCEPTED; 1053 m->friendlist[friendnumber].file_sending[i].status = FILESTATUS_NOT_ACCEPTED;
1047 m->friendlist[friendnumber].file_sending[i].size = filesize; 1054 m->friendlist[friendnumber].file_sending[i].size = filesize;
1048 m->friendlist[friendnumber].file_sending[i].transferred = 0; 1055 m->friendlist[friendnumber].file_sending[i].transferred = 0;
1056 m->friendlist[friendnumber].file_sending[i].type = file_type;
1049 return i; 1057 return i;
1050} 1058}
1051 1059
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index fa0d241c..ca6b4896 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -129,6 +129,7 @@ struct File_Transfers {
129 uint64_t size; 129 uint64_t size;
130 uint64_t transferred; 130 uint64_t transferred;
131 uint8_t status; /* 0 == no transfer, 1 = not accepted, 2 = paused by the other, 3 = transferring, 4 = broken, 5 = paused by us */ 131 uint8_t status; /* 0 == no transfer, 1 = not accepted, 2 = paused by the other, 3 = transferring, 4 = broken, 5 = paused by us */
132 unsigned int type;
132}; 133};
133enum { 134enum {
134 FILESTATUS_NONE, 135 FILESTATUS_NONE,
@@ -579,10 +580,14 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, uint32_t, u
579/* Send a file send request. 580/* Send a file send request.
580 * Maximum filename length is 255 bytes. 581 * Maximum filename length is 255 bytes.
581 * return file number on success 582 * return file number on success
582 * return -1 on failure 583 * return -1 if friend not found.
584 * return -2 if filename too big.
585 * return -3 if no more file sending slots left.
586 * return -4 if could not send packet (friend offline).
587 *
583 */ 588 */
584int new_filesender(const Messenger *m, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, 589long int new_filesender(const Messenger *m, int32_t friendnumber, uint32_t file_type, uint64_t filesize,
585 uint16_t filename_length); 590 const uint8_t *filename, uint16_t filename_length);
586 591
587/* Send a file control request. 592/* Send a file control request.
588 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. 593 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.