~ehmry/nim_tox

285d5e063961a7fa84baa19d4106d4d63ad89e96 — Emery Hemingway 1 year, 11 months ago ca12034
Rename File type to FileTransfer
1 files changed, 23 insertions(+), 23 deletions(-)

M src/toxcore.nim
M src/toxcore.nim => src/toxcore.nim +23 -23
@@ 141,7 141,7 @@ type
    ## Cookie attached to Tox addresses and friend requests.
  MessageId* = distinct uint32
    ## Token for referencing application messages.
  File* = distinct uint32
  FileTransfer* = distinct uint32
    ## Token for referencing file transfers.
  Conference* = distinct uint32
    ## Token for referencing conferences.


@@ 228,13 228,13 @@ type
    friend: Friend; msg: string; kind: TOX_MESSAGE_TYPE) {.gcsafe.}

  CbFileRecvControl* = proc (
    friend: Friend; file: File; control: TOX_FILE_CONTROL) {.gcsafe.}
    friend: Friend; file: FileTransfer; control: TOX_FILE_CONTROL) {.gcsafe.}
  CbFileChunkRequest* = proc (
    friend: Friend; file: File; pos: uint64; size: int) {.gcsafe.}
    friend: Friend; file: FileTransfer; pos: uint64; size: int) {.gcsafe.}
  CbFileRecv* = proc (
    friend: Friend; file: File; kind: uint32; size: uint64; filename: string) {.gcsafe.}
    friend: Friend; file: FileTransfer; kind: uint32; size: uint64; filename: string) {.gcsafe.}
  CbFileRecvChunk* = proc (
    friend: Friend; file: File; pos: uint64; data: pointer; size: int) {.gcsafe.}
    friend: Friend; file: FileTransfer; pos: uint64; data: pointer; size: int) {.gcsafe.}

  CbConferenceInvite* = proc (
    friend: Friend; kind: TOX_CONFERENCE_TYPE; cookie: string) {.gcsafe.}


@@ 862,9 862,9 @@ type Tox_Err_File_Control = enum
    TOX_ERR_FILE_CONTROL_ALREADY_PAUSED,
    TOX_ERR_FILE_CONTROL_SENDQ

proc control*(tox: Tox; friend: Friend; file: File; control: TOX_FILE_CONTROL) {.tags: [IOEffect].} =
proc control*(tox: Tox; friend: Friend; file: FileTransfer; control: TOX_FILE_CONTROL) {.tags: [IOEffect].} =
  proc file_control(
    core: Core; friend: Friend; file: File;
    core: Core; friend: Friend; file: FileTransfer;
    control: TOX_FILE_CONTROL;
    error: ptr TOX_ERR_FILE_CONTROL): bool {.ctoxProc.}
  var err: Tox_Err_File_Control


@@ 874,11 874,11 @@ proc control*(tox: Tox; friend: Friend; file: File; control: TOX_FILE_CONTROL) {
callbackSetter file_recv_control:
  type cbType = proc (
    core: Core; friend: Friend;
    file: File; control: TOX_FILE_CONTROL;
    file: FileTransfer; control: TOX_FILE_CONTROL;
    user_data: pointer) {.cdecl.}
  proc wrapper(
      core: Core; friend: Friend;
      file: File; control: TOX_FILE_CONTROL;
      file: FileTransfer; control: TOX_FILE_CONTROL;
      user_data: pointer) {.cdecl.} =
    callThru(friend, file, control)



@@ 891,9 891,9 @@ type Tox_Err_File_Seek = enum
    TOX_ERR_FILE_SEEK_INVALID_POSITION,
    TOX_ERR_FILE_SEEK_SENDQ

proc seek*(tox: Tox; friend: Friend; file: File; pos: uint64) {.tags: [IOEffect].} =
proc seek*(tox: Tox; friend: Friend; file: FileTransfer; pos: uint64) {.tags: [IOEffect].} =
  proc file_seek(
    core: Core; friend: Friend; file: File;
    core: Core; friend: Friend; file: FileTransfer;
    position: uint64; error: ptr Tox_Err_File_Seek): bool {.ctoxProc.}
  var err: Tox_Err_File_Seek
  discard tox.core.file_seek(friend, file, pos, addr err)


@@ 905,10 905,10 @@ type Tox_Err_File_Get = enum
    TOX_ERR_FILE_GET_FRIEND_NOT_FOUND,
    TOX_ERR_FILE_GET_NOT_FOUND

proc id*(tox: Tox; friend: Friend; file: File): FileId =
proc id*(tox: Tox; friend: Friend; file: FileTransfer): FileId =
  proc file_get_file_id(
    core: Core; friend: Friend;
    file: File; file_id: ptr uint8;
    file: FileTransfer; file_id: ptr uint8;
    error: ptr Tox_Err_File_Get): bool {.ctoxProc.}
  var err: Tox_Err_File_Get
  discard tox.core.file_get_file_id(friend, file, addr result.bytes[0], addr err)


@@ 922,14 922,14 @@ type Tox_Err_File_Send = enum
    TOX_ERR_FILE_SEND_NAME_TOO_LONG,
    TOX_ERR_FILE_SEND_TOO_MANY

proc send*(tox: Tox; friend: Friend; kind: uint32; size: uint64; id: FileId; filename: string): File {.tags: [IOEffect].} =
proc send*(tox: Tox; friend: Friend; kind: uint32; size: BiggestInt; id: FileId; filename: string): FileTransfer {.tags: [IOEffect].} =
  proc file_send(
    core: Core; friend: Friend; kind: uint32;
    file_size: uint64; file_id: ptr uint8; filename: ptr char;
    filename_length: csize; error: ptr Tox_Err_File_Send): File {.ctoxProc.}
  var err: Tox_Err_File_Send
  result = tox.core.file_send(
    friend, kind, size, unsafeAddr id.bytes[0], unsafeAddr filename[0], filename.len, addr err)
    friend, kind, size.uint64, unsafeAddr id.bytes[0], unsafeAddr filename[0], filename.len, addr err)
  ctoxAssert(TOX_ERR_FILE_SEND_OK, err)

type Tox_Err_File_Send_Chunk = enum


@@ 943,10 943,10 @@ type Tox_Err_File_Send_Chunk = enum
    TOX_ERR_FILE_SEND_CHUNK_SENDQ,
    TOX_ERR_FILE_SEND_CHUNK_WRONG_POSITION

proc sendChunk*(tox: Tox; friend: Friend; file: File; pos: uint64; data: pointer; size: int) {.tags: [IOEffect].} =
proc sendChunk*(tox: Tox; friend: Friend; file: FileTransfer; pos: uint64; data: pointer; size: int) {.tags: [IOEffect].} =
  proc file_send_chunk(
    core: Core; friend: Friend;
    file: File; position: uint64;
    file: FileTransfer; position: uint64;
    data: pointer; length: csize;
    error: ptr Tox_Err_File_Send_Chunk): bool {.ctoxProc.}
  var err: Tox_Err_File_Send_Chunk


@@ 956,23 956,23 @@ proc sendChunk*(tox: Tox; friend: Friend; file: File; pos: uint64; data: pointer
callbackSetter file_chunk_request:
  type cbType = proc (
    core: Core; friend: Friend;
    file: File; position: uint64;
    file: FileTransfer; position: uint64;
    length: csize; user_data: pointer) {.cdecl.}
  proc wrapper(
      core: Core; friend: Friend;
      file: File; position: uint64;
      file: FileTransfer; position: uint64;
      length: csize; user_data: pointer) {.cdecl.} =
    callThru(friend, file, position, length)

callbackSetter file_recv:
  type cbType = proc (
    core: Core; friend: Friend;
    file: File; kind: uint32; file_size: uint64;
    file: FileTransfer; kind: uint32; file_size: uint64;
    filename: ptr uint8; filename_length: csize;
    user_data: pointer) {.cdecl.}
  proc wrapper(
      core: Core; friend: Friend;
      file: File; kind: uint32; file_size: uint64;
      file: FileTransfer; kind: uint32; file_size: uint64;
      filename: ptr uint8; filename_length: csize;
      user_data: pointer) {.cdecl.} =
    callThru(friend, file, kind, fileSize, ctoxString(filename, filenameLength))


@@ 980,11 980,11 @@ callbackSetter file_recv:
callbackSetter file_recv_chunk:
  type cbType = proc (
    core: Core; friend: Friend;
    file: File; position: uint64;
    file: FileTransfer; position: uint64;
    data: ptr uint8; length: csize; user_data: pointer) {.cdecl.}
  proc wrapper(
      core: Core; friend: Friend;
      file: File; position: uint64;
      file: FileTransfer; position: uint64;
      data: ptr uint8; length: csize; user_data: pointer) {.cdecl.} =
    callThru(friend, file, position, data, length)