summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2014-09-15 14:40:16 +0100
committersin <sin@2f30.org>2014-09-15 14:40:16 +0100
commit0cd844914b1fa5bca3c881c35df7db3d6d4a058c (patch)
treed5abcf3124c7982e9fee9b57f7dd7aa48eff5804
parent11fccffc5de8321a66b7ab813ff0f99e92daa657 (diff)
Create files even if the friend is not yet in our list
-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