diff options
author | Coren[m] <Break@Ocean> | 2013-11-12 19:56:32 +0100 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-11-12 19:57:01 +0100 |
commit | 6d31a9be7ecf486793ba4eb4296eb08429071a7d (patch) | |
tree | 68cf6a374769b679cd3aaf34f5e8ae595fea1575 /toxcore/Messenger.c | |
parent | ba000a24248ec3c4053201c5822d2334d34712f8 (diff) |
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
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 14 |
1 files changed, 14 insertions, 0 deletions
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) | |||
435 | for (i = 0; i < m->numfriends; ++i) | 435 | for (i = 0; i < m->numfriends; ++i) |
436 | m->friendlist[i].name_sent = 0; | 436 | m->friendlist[i].name_sent = 0; |
437 | 437 | ||
438 | for (i = 0; i < m->numchats; i++) | ||
439 | m->chats[i]->last_sent_nick = 0; /* or send the new name right away? */ | ||
440 | |||
438 | return 0; | 441 | return 0; |
439 | } | 442 | } |
440 | 443 | ||
@@ -969,6 +972,17 @@ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t | |||
969 | if (m->chats[groupnumber] == NULL) | 972 | if (m->chats[groupnumber] == NULL) |
970 | return -1; | 973 | return -1; |
971 | 974 | ||
975 | /* send own nick from time to time, to let newly added peers be informed | ||
976 | * first time only: use a shorter timeframe, because we might not be in our own | ||
977 | * peer list yet */ | ||
978 | if (is_timeout(m->chats[groupnumber]->last_sent_nick, 180)) | ||
979 | if (group_send_nick(m->chats[groupnumber], m->chats[groupnumber]->self_public_key, m->name, m->name_length) > 0) { | ||
980 | if (!m->chats[groupnumber]->last_sent_nick) | ||
981 | m->chats[groupnumber]->last_sent_nick = unix_time() - 150; | ||
982 | else | ||
983 | m->chats[groupnumber]->last_sent_nick = unix_time(); | ||
984 | } | ||
985 | |||
972 | if (group_sendmessage(m->chats[groupnumber], message, length) > 0) | 986 | if (group_sendmessage(m->chats[groupnumber], message, length) > 0) |
973 | return 0; | 987 | return 0; |
974 | 988 | ||