summaryrefslogtreecommitdiff
path: root/ratatox.c
diff options
context:
space:
mode:
Diffstat (limited to 'ratatox.c')
-rw-r--r--ratatox.c26
1 files 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