summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-03-17 15:05:17 -0400
committerirungentoo <irungentoo@gmail.com>2015-03-17 15:05:17 -0400
commitea8d27259f7d0314b08f6eb32edf15fec3822530 (patch)
tree1479c057231a83715963a9c4edf41f8dbb2c7a70 /toxcore/tox.c
parente072079620d7353fc06e1c2ba6d4b5228d444422 (diff)
Added tox_file_send_seek() function to api.
This function can be used to seek an incoming file tranfer right before accepting it. It is meant to be used to resume incomplete file tranfers by clients.
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 36f87cc6..87b8e8de 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -883,6 +883,48 @@ bool tox_file_send_control(Tox *tox, uint32_t friend_number, uint32_t file_numbe
883 return 0; 883 return 0;
884} 884}
885 885
886bool tox_file_send_seek(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
887 TOX_ERR_FILE_SEEK *error)
888{
889 Messenger *m = tox;
890 int ret = file_seek(m, friend_number, file_number, position);
891
892 if (ret == 0) {
893 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_OK);
894 return 1;
895 }
896
897 switch (ret) {
898 case -1:
899 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_FRIEND_NOT_FOUND);
900 return 0;
901
902 case -2:
903 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_FRIEND_NOT_CONNECTED);
904 return 0;
905
906 case -3:
907 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_NOT_FOUND);
908 return 0;
909
910 case -4:
911 case -5:
912 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_DENIED);
913 return 0;
914
915 case -6:
916 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_INVALID_POSITION);
917 return 0;
918
919 case -8:
920 SET_ERROR_PARAMETER(error, TOX_ERR_FILE_SEEK_SEND_FAILED);
921 return 0;
922 }
923
924 /* can't happen */
925 return 0;
926}
927
886void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function, void *user_data) 928void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function, void *user_data)
887{ 929{
888 Messenger *m = tox; 930 Messenger *m = tox;