diff --git a/src/groupchat.c b/src/groupchat.c index bf721c4..70bc426 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -288,11 +288,9 @@ static void groupchat_onGroupTitleChange(ToxWindow *self, Tox *m, int groupnum, char timefrmt[TIME_STR_SIZE]; get_time_str(timefrmt, sizeof(timefrmt)); - /* announce title when we join the room */ - if (!timed_out(groupchats[self->num].start_time, get_unix_time(), GROUP_EVENT_WAIT)) { - line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is set to: %s", title); + /* don't announce title when we join the room */ + if (!timed_out(groupchats[self->num].start_time, get_unix_time(), GROUP_EVENT_WAIT)) return; - } char nick[TOX_MAX_NAME_LENGTH]; get_group_nick_truncate(m, nick, peernum, groupnum); diff --git a/src/misc_tools.c b/src/misc_tools.c index d89c046..0b977b2 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -261,10 +261,17 @@ void str_to_lower(char *str) } /* puts friendnum's nick in buf, truncating at TOXIC_MAX_NAME_LENGTH if necessary. - Returns nick len on success, -1 on failure */ + if toxcore API call fails, put UNKNOWN_NAME in buf + Returns nick len */ int get_nick_truncate(Tox *m, char *buf, int friendnum) { int len = tox_get_name(m, friendnum, (uint8_t *) buf); + + if (len == -1) { + strcpy(buf, UNKNOWN_NAME); + len = strlen(UNKNOWN_NAME); + } + len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1); buf[len] = '\0'; filter_str(buf, len); @@ -275,6 +282,12 @@ int get_nick_truncate(Tox *m, char *buf, int friendnum) int get_group_nick_truncate(Tox *m, char *buf, int peernum, int groupnum) { int len = tox_group_peername(m, groupnum, peernum, (uint8_t *) buf); + + if (len == -1) { + strcpy(buf, UNKNOWN_NAME); + len = strlen(UNKNOWN_NAME); + } + len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1); buf[len] = '\0'; filter_str(buf, len);