diff options
author | irungentoo <irungentoo@gmail.com> | 2013-11-12 20:59:32 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-11-12 20:59:32 -0500 |
commit | 5e6fbf33b5a9865663c7004d005013d586cdf6b3 (patch) | |
tree | 74a1416d30987dadc3070f0c3c4d294ff63bdb2f /toxcore/Messenger.c | |
parent | 244c625e51cc2019dd14c894a79af2d762e822e0 (diff) |
Cleaned up the code.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 6ec54587..57cafc3f 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -436,7 +436,8 @@ int setname(Messenger *m, uint8_t *name, uint16_t length) | |||
436 | m->friendlist[i].name_sent = 0; | 436 | m->friendlist[i].name_sent = 0; |
437 | 437 | ||
438 | for (i = 0; i < m->numchats; i++) | 438 | for (i = 0; i < m->numchats; i++) |
439 | m->chats[i]->last_sent_nick = 0; /* or send the new name right away? */ | 439 | if (m->chats[i] != NULL) |
440 | set_nick(m->chats[i], name, length); /* TODO: remove this (group nicks should not be tied to the global one) */ | ||
440 | 441 | ||
441 | return 0; | 442 | return 0; |
442 | } | 443 | } |
@@ -789,6 +790,8 @@ int add_groupchat(Messenger *m) | |||
789 | return -1; | 790 | return -1; |
790 | 791 | ||
791 | callback_groupmessage(newchat, &group_message_function, m); | 792 | callback_groupmessage(newchat, &group_message_function, m); |
793 | /* TODO: remove this (group nicks should not be tied to the global one) */ | ||
794 | set_nick(newchat, m->name, m->name_length); | ||
792 | m->chats[i] = newchat; | 795 | m->chats[i] = newchat; |
793 | return i; | 796 | return i; |
794 | } | 797 | } |
@@ -807,6 +810,8 @@ int add_groupchat(Messenger *m) | |||
807 | 810 | ||
808 | m->chats = temp; | 811 | m->chats = temp; |
809 | callback_groupmessage(temp[m->numchats], &group_message_function, m); | 812 | callback_groupmessage(temp[m->numchats], &group_message_function, m); |
813 | /* TODO: remove this (group nicks should not be tied to the global one) */ | ||
814 | set_nick(temp[m->numchats], m->name, m->name_length); | ||
810 | ++m->numchats; | 815 | ++m->numchats; |
811 | return (m->numchats - 1); | 816 | return (m->numchats - 1); |
812 | } | 817 | } |
@@ -972,17 +977,6 @@ int group_message_send(Messenger *m, int groupnumber, uint8_t *message, uint32_t | |||
972 | if (m->chats[groupnumber] == NULL) | 977 | if (m->chats[groupnumber] == NULL) |
973 | return -1; | 978 | return -1; |
974 | 979 | ||
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 | |||
986 | if (group_sendmessage(m->chats[groupnumber], message, length) > 0) | 980 | if (group_sendmessage(m->chats[groupnumber], message, length) > 0) |
987 | return 0; | 981 | return 0; |
988 | 982 | ||