~ehmry/nim_tox

fd12809b8133ea8ed68a34f392983e543e18243e — Emery Hemingway 1 year, 3 months ago 008aff3 v0.2.1
Add sugar for sendChunk
1 files changed, 9 insertions(+), 2 deletions(-)

M src/toxcore.nim
M src/toxcore.nim => src/toxcore.nim +9 -2
@@ 935,7 935,7 @@ type Err_File_Send {.ctoxEnum.} = enum
  TOX_ERR_FILE_SEND_NAME_TOO_LONG,
  TOX_ERR_FILE_SEND_TOO_MANY

proc send*(tox: Tox; friend: Friend; kind: uint32; size: BiggestInt; id: FileId;
proc send*(tox: Tox; friend: Friend; kind: uint32; size: BiggestInt;
    filename: string): FileTransfer {.tags: [IOEffect].} =
  proc file_send(
    core: Core; friend: Friend; kind: uint32;


@@ 943,7 943,7 @@ proc send*(tox: Tox; friend: Friend; kind: uint32; size: BiggestInt; id: FileId;
    filename_length: csize; error: ptr Err_File_Send): FileTransfer {.ctoxProc.}
  var err: Err_File_Send
  result = tox.core.file_send(
    friend, kind, size.uint64, unsafeAddr id[0], filename, filename.len, addr err)
    friend, kind, size.uint64, nil, filename, filename.len, addr err)
  ctoxAssert(TOX_ERR_FILE_SEND_OK, err)

type Err_File_Send_Chunk {.ctoxEnum.} = enum


@@ 968,6 968,13 @@ proc sendChunk*(tox: Tox; friend: Friend; file: FileTransfer; pos: uint64;
  discard tox.core.file_send_chunk(friend, file, pos, data, size, addr err)
  ctoxAssert(TOX_ERR_FILE_SEND_CHUNK_OK, err)

proc sendChunk*(tox: Tox; friend: Friend; file: FileTransfer; pos: uint64;
    data: string) =
  if data.len == 0:
    sendChunk(tox, friend, file, pos, nil, 0)
  else:
    sendChunk(tox, friend, file, pos, data[0].unsafeAddr, data.len)

callbackSetter file_chunk_request:
  type cbType = proc (
    core: Core; friend: Friend;