From 6d31a9be7ecf486793ba4eb4296eb08429071a7d Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Tue, 12 Nov 2013 19:56:32 +0100 Subject: Group chat: Add a nickname message. Remove strange default nickname. (Seriously...) group_chats.*: - group_send_nick() to send own name - setnick() to store a received name Messenger.c: - group_send_nick() before group_sendmessage() (in regular intervals, to inform new peers) nTox.c: - print_groupmessage(): on error or on a name of length zero the result of tox_group_peername() isn't null-terminated, catch that --- toxcore/Messenger.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'toxcore/Messenger.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 659c837b..12c59cb3 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -435,6 +435,9 @@ int setname(Messenger *m, uint8_t *name, uint16_t length) for (i = 0; i < m->numfriends; ++i) m->friendlist[i].name_sent = 0; + for (i = 0; i < m->numchats; i++) + m->chats[i]->last_sent_nick = 0; /* or send the new name right away? */ + return 0; } @@ -969,6 +972,17 @@ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t if (m->chats[groupnumber] == NULL) return -1; + /* send own nick from time to time, to let newly added peers be informed + * first time only: use a shorter timeframe, because we might not be in our own + * peer list yet */ + if (is_timeout(m->chats[groupnumber]->last_sent_nick, 180)) + if (group_send_nick(m->chats[groupnumber], m->chats[groupnumber]->self_public_key, m->name, m->name_length) > 0) { + if (!m->chats[groupnumber]->last_sent_nick) + m->chats[groupnumber]->last_sent_nick = unix_time() - 150; + else + m->chats[groupnumber]->last_sent_nick = unix_time(); + } + if (group_sendmessage(m->chats[groupnumber], message, length) > 0) return 0; -- cgit v1.2.3