From 0cd844914b1fa5bca3c881c35df7db3d6d4a058c Mon Sep 17 00:00:00 2001 From: sin Date: Mon, 15 Sep 2014 14:40:16 +0100 Subject: Create files even if the friend is not yet in our list --- ratatox.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ratatox.c b/ratatox.c index 63ec2ab..8aa3c2e 100644 --- a/ratatox.c +++ b/ratatox.c @@ -217,23 +217,21 @@ cb_conn_status(Tox *tox, int32_t fid, uint8_t status, void *udata) printf("%s %s\n", n == 0 ? (uint8_t *)"Anonymous" : name, status == 0 ? "went offline" : "came online"); - TAILQ_FOREACH(f, &friendhead, entry) { - if (f->fid == fid) { - blabla(f, "online", "w", status == 0 ? "0\n" : "1\n"); - if (status == 1) { - blabla(f, "name", "w", "%s\n", name); - n = tox_get_status_message_size(tox, fid); - if (n > TOX_MAX_STATUSMESSAGE_LENGTH + 1) - n = TOX_MAX_STATUSMESSAGE_LENGTH; - statusmsg[n] = '\0'; - blabla(f, "statusmsg", "w", "%s\n", statusmsg); - } - return; - } - } + TAILQ_FOREACH(f, &friendhead, entry) + if (f->fid == fid) + goto out; f = friendcreate(fid); +out: blabla(f, "online", "w", status == 0 ? "0\n" : "1\n"); + if (status == 1) { + blabla(f, "name", "w", "%s\n", name); + n = tox_get_status_message_size(tox, fid); + if (n > TOX_MAX_STATUSMESSAGE_LENGTH + 1) + n = TOX_MAX_STATUSMESSAGE_LENGTH; + statusmsg[n] = '\0'; + blabla(f, "statusmsg", "w", "%s\n", statusmsg); + } } static void -- cgit v1.2.3