ratox

FIFO based tox client
git clone git://git.2f30.org/ratox
Log | Files | Refs | README | LICENSE

commit 9e1d2b5522bfb88474570ffebd6546f2d4bf445f
parent 91b1e85c3fd92e57027672e459fa050c801113e1
Author: FRIGN <dev@frign.de>
Date:   Mon, 13 Oct 2014 22:35:04 +0200

Change the state-files

rename file_pending to file_state
rename call_pending to call_state
	0 = no call
	1 = call pending
	2 = call active

Diffstat:
Mratox.c | 67++++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 36 insertions(+), 31 deletions(-)

diff --git a/ratox.c b/ratox.c @@ -119,24 +119,24 @@ enum { FNAME, FSTATUS, FSTATE, - FFILE_PENDING, - FCALL_PENDING, + FFILE_STATE, + FCALL_STATE, }; static struct file ffiles[] = { - [FTEXT_IN] = { .type = FIFO, .name = "text_in", .flags = O_RDONLY | O_NONBLOCK }, - [FFILE_IN] = { .type = FIFO, .name = "file_in", .flags = O_RDONLY | O_NONBLOCK }, - [FCALL_IN] = { .type = FIFO, .name = "call_in", .flags = O_RDONLY | O_NONBLOCK }, - [FTEXT_OUT] = { .type = STATIC, .name = "text_out", .flags = O_WRONLY | O_APPEND | O_CREAT }, - [FFILE_OUT] = { .type = FIFO, .name = "file_out", .flags = O_WRONLY | O_NONBLOCK }, - [FCALL_OUT] = { .type = FIFO, .name = "call_out", .flags = O_WRONLY | O_NONBLOCK }, - [FREMOVE] = { .type = FIFO, .name = "remove", .flags = O_RDONLY | O_NONBLOCK }, - [FONLINE] = { .type = STATIC, .name = "online", .flags = O_WRONLY | O_TRUNC | O_CREAT }, - [FNAME] = { .type = STATIC, .name = "name", .flags = O_WRONLY | O_TRUNC | O_CREAT }, - [FSTATUS] = { .type = STATIC, .name = "status", .flags = O_WRONLY | O_TRUNC | O_CREAT }, - [FSTATE] = { .type = STATIC, .name = "state", .flags = O_WRONLY | O_TRUNC | O_CREAT }, - [FFILE_PENDING] = { .type = STATIC, .name = "file_pending", .flags = O_WRONLY | O_TRUNC | O_CREAT }, - [FCALL_PENDING] = { .type = STATIC, .name = "call_pending", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FTEXT_IN] = { .type = FIFO, .name = "text_in", .flags = O_RDONLY | O_NONBLOCK }, + [FFILE_IN] = { .type = FIFO, .name = "file_in", .flags = O_RDONLY | O_NONBLOCK }, + [FCALL_IN] = { .type = FIFO, .name = "call_in", .flags = O_RDONLY | O_NONBLOCK }, + [FTEXT_OUT] = { .type = STATIC, .name = "text_out", .flags = O_WRONLY | O_APPEND | O_CREAT }, + [FFILE_OUT] = { .type = FIFO, .name = "file_out", .flags = O_WRONLY | O_NONBLOCK }, + [FCALL_OUT] = { .type = FIFO, .name = "call_out", .flags = O_WRONLY | O_NONBLOCK }, + [FREMOVE] = { .type = FIFO, .name = "remove", .flags = O_RDONLY | O_NONBLOCK }, + [FONLINE] = { .type = STATIC, .name = "online", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FNAME] = { .type = STATIC, .name = "name", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FSTATUS] = { .type = STATIC, .name = "status", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FSTATE] = { .type = STATIC, .name = "state", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FFILE_STATE] = { .type = STATIC, .name = "file_pending", .flags = O_WRONLY | O_TRUNC | O_CREAT }, + [FCALL_STATE] = { .type = STATIC, .name = "call_state", .flags = O_WRONLY | O_TRUNC | O_CREAT }, }; static char *ustate[] = { @@ -388,9 +388,9 @@ cbcallinvite(void *av, int32_t cnum, void *udata) logmsg(": %s : Rx AV > Audio call settings: srate = %lu, channels = %lu\n", f->name, avconfig.audio_sample_rate, avconfig.audio_channels); - ftruncate(f->fd[FCALL_PENDING], 0); - lseek(f->fd[FCALL_PENDING], 0, SEEK_SET); - dprintf(f->fd[FCALL_PENDING], "1\n"); + ftruncate(f->fd[FCALL_STATE], 0); + lseek(f->fd[FCALL_STATE], 0, SEEK_SET); + dprintf(f->fd[FCALL_STATE], "1\n"); } static void @@ -422,6 +422,11 @@ cbcallstart(void *av, int32_t cnum, void *udata) return; } f->av.transmission = 1; + + ftruncate(f->fd[FCALL_STATE], 0); + lseek(f->fd[FCALL_STATE], 0, SEEK_SET); + dprintf(f->fd[FCALL_STATE], "2\n"); + logmsg(": %s : Rx/Tx AV > Started\n", f->name); } @@ -507,9 +512,9 @@ cancelcall(struct friend *f, char *action) close(f->fd[FCALL_OUT]); f->fd[FCALL_OUT] = -1; } - ftruncate(f->fd[FCALL_PENDING], 0); - lseek(f->fd[FCALL_PENDING], 0, SEEK_SET); - dprintf(f->fd[FCALL_PENDING], "0\n"); + ftruncate(f->fd[FCALL_STATE], 0); + lseek(f->fd[FCALL_STATE], 0, SEEK_SET); + dprintf(f->fd[FCALL_STATE], "0\n"); /* Cancel Tx side of the call */ free(f->av.frame); @@ -792,8 +797,8 @@ cbfilecontrol(Tox *m, int32_t frnum, uint8_t rec_sen, uint8_t fnum, uint8_t ctrl close(f->fd[FFILE_OUT]); f->fd[FFILE_OUT] = -1; } - ftruncate(f->fd[FFILE_PENDING], 0); - lseek(f->fd[FFILE_PENDING], 0, SEEK_SET); + ftruncate(f->fd[FFILE_STATE], 0); + lseek(f->fd[FFILE_STATE], 0, SEEK_SET); f->rxstate = TRANSFER_NONE; } break; @@ -828,9 +833,9 @@ cbfilesendreq(Tox *m, int32_t frnum, uint8_t fnum, uint64_t fsz, return; } - ftruncate(f->fd[FFILE_PENDING], 0); - lseek(f->fd[FFILE_PENDING], 0, SEEK_SET); - dprintf(f->fd[FFILE_PENDING], "%s\n", filename); + ftruncate(f->fd[FFILE_STATE], 0); + lseek(f->fd[FFILE_STATE], 0, SEEK_SET); + dprintf(f->fd[FFILE_STATE], "%s\n", filename); f->rxstate = TRANSFER_PENDING; logmsg(": %s : Rx > Pending %s\n", f->name, filename); } @@ -892,8 +897,8 @@ cancelrxtransfer(struct friend *f) close(f->fd[FFILE_OUT]); f->fd[FFILE_OUT] = -1; } - ftruncate(f->fd[FFILE_PENDING], 0); - lseek(f->fd[FFILE_PENDING], 0, SEEK_SET); + ftruncate(f->fd[FFILE_STATE], 0); + lseek(f->fd[FFILE_STATE], 0, SEEK_SET); f->rxstate = TRANSFER_NONE; } @@ -1342,11 +1347,11 @@ friendcreate(int32_t frnum) } /* Dump file pending state */ - ftruncate(f->fd[FFILE_PENDING], 0); + ftruncate(f->fd[FFILE_STATE], 0); /* Dump call pending state */ - ftruncate(f->fd[FCALL_PENDING], 0); - dprintf(f->fd[FCALL_PENDING], "0\n"); + ftruncate(f->fd[FCALL_STATE], 0); + dprintf(f->fd[FCALL_STATE], "0\n"); f->av.transmission = 0; f->av.num = -1;