C-toxcore: Indicate that group chat peer's username is not known

Created on 6 Feb 2018  路  4Comments  路  Source: TokTok/c-toxcore

In group chat when a joining peer's username is not known a string "Tox User" is returned. As far as I know toxcore gives no other indication about this. That means clients can never trust if the peer's name they got from toxcore is correct or not. "Tox User" can be a legitimate username, so there is no way to distinguish if it's a correct name. This makes creating join notifications for group chats difficult.

When a user joins a group chat we are in, we will at first see their name as "Tox User". Then it will probably get changed to their real name calling TOX_CONFERENCE_STATE_CHANGE_PEER_NAME_CHANGE. I don't know how clients get around it, but this should be changed.

in group.c:

/* Copy the name of peer_index who is in groupnumber to name.
 * name must be at least MAX_NAME_LENGTH long.
 *
 * return length of name if success
 * return -1 if groupnumber is invalid.
 * return -2 if peer_index is invalid.
 */
int group_peername(const Group_Chats *g_c, int groupnumber, int peer_index, uint8_t *name)
{
    Group_c *g = get_group_c(g_c, groupnumber);

    if (!g) {
        return -1;
    }

    if (peer_index < 0 || (uint32_t)peer_index >= g->numpeers_in_list) {
        return -2;
    }

    if (g->peers_list[peer_index] == INVALID_PEER_INDEX) {
        return -2;
    }

    Group_Peer *peer = &g->peers[g->peers_list[peer_index]];

    peer->nick_changed = false;

    if (peer->nick_len == 0) {
        memcpy(name, "Tox User", 8);
        return 8;
    }

    memcpy(name, peer->nick, peer->nick_len);
    return peer->nick_len;
}
enhancement

Most helpful comment

What about using an empty string instead of using Tox User?

All 4 comments

What about using an empty string instead of using Tox User?

maybe somewhere along this line:

    if (peer->nick_len == 0) {
        name[0] = '\0';
        return 0;
    }

There has to be some default name. We could set it to an empty string and let clients decide what the default name should be, but then it will be different in each client.

There is also another problem. Why is the string "Tox User" returned for every peer that joins and changed to user's real name later? It must mean that every joining user's name is empty at first. Why?

We could set it to an empty string and let clients decide what the default name should be, but then it will be different in each client.

I think letting the client decide the default name wouldn't be to bad, qTox already has a default name when you create a profile, wouldn't be much work to make one for groups.

Why is the string "Tox User" returned for every peer that joins and changed to user's real name later?

Maybe the packet indicating the peer name arrives after the one indicating someone joined the group? Not sure what the protocol says here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iphydf picture iphydf  路  5Comments

fabionar picture fabionar  路  5Comments

hkarel picture hkarel  路  8Comments

DataMaster-2501 picture DataMaster-2501  路  6Comments

ovalseven8 picture ovalseven8  路  11Comments