ratox

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

commit d0c3a52050c8fdab224b612f4185a40d4d87bd04
parent 207fdb2bd1873c2e75b4337681e4c73e351e25e1
Author: FRIGN <dev@frign.de>
Date:   Thu,  2 Oct 2014 11:25:43 +0200

Add cancelrxcall()

Diffstat:
Mratox.c | 33+++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/ratox.c b/ratox.c @@ -199,6 +199,7 @@ static void cbreqtimeout(void *, int32_t, void *); static void cbpeertimeout(void *, int32_t, void *); static void cbcalltypechange(void *, int32_t, void *); static void cbcalldata(ToxAv *, int32_t, int16_t *, int, void *); +static void cancelrxcall(struct friend *, char *); static void cbconnstatus(Tox *, int32_t, uint8_t, void *); static void cbfriendmessage(Tox *, int32_t, const uint8_t *, uint16_t, void *); static void cbfriendrequest(Tox *, const uint8_t *, const uint8_t *, uint16_t, void *); @@ -390,14 +391,7 @@ cbcallended(void *av, int32_t cnum, void *udata) if (!f) return; - printout(": %s : Rx AV > Ended call\n", f->name); - f->avstate = av_CallNonExistant; - if (f->fd[FCALL_OUT] != -1) { - close(f->fd[FCALL_OUT]); - f->fd[FCALL_OUT] = -1; - } - ftruncate(f->fd[FCALL_PENDING], 0); - dprintf(f->fd[FCALL_PENDING], "0\n"); + cancelrxcall(f, "Ended"); } static void @@ -413,14 +407,7 @@ cbcallcancelled(void *av, int32_t cnum, void *udata) if (!f) return; - printout(": %s : Rx AV > Cancelled\n", f->name); - f->avstate = av_CallNonExistant; - if (f->fd[FCALL_OUT] != -1) { - close(f->fd[FCALL_OUT]); - f->fd[FCALL_OUT] = -1; - } - ftruncate(f->fd[FCALL_PENDING], 0); - dprintf(f->fd[FCALL_PENDING], "0\n"); + cancelrxcall(f, "Cancelled"); } static void @@ -502,6 +489,20 @@ cbcalldata(ToxAv *av, int32_t cnum, int16_t *data, int len, void *udata) } static void +cancelrxcall(struct friend *f, char *action) +{ + printout(": %s : Rx AV > %s\n", f->name, action); + f->avstate = av_CallNonExistant; + if (f->fd[FCALL_OUT] != -1) { + close(f->fd[FCALL_OUT]); + f->fd[FCALL_OUT] = -1; + } + ftruncate(f->fd[FCALL_PENDING], 0); + dprintf(f->fd[FCALL_PENDING], "0\n"); +} + + +static void cbconnstatus(Tox *m, int32_t frnum, uint8_t status, void *udata) { struct friend *f;