1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 20:53:01 +01:00

set friendnames using api function

This commit is contained in:
Jfreegman 2013-09-23 15:43:02 -04:00
parent e6956b1abc
commit d76c80951b
2 changed files with 4 additions and 5 deletions

View File

@ -226,8 +226,6 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int friendnum , u
if (tox_getname(m, friendnum, nick) == -1)
return;
nick[TOXIC_MAX_NAME_LENGTH] = '\0';
if (!nick[0])
snprintf(nick, sizeof(nick), "%s", UNKNOWN_NAME);
@ -281,7 +279,6 @@ static void prompt_onGroupInvite(ToxWindow *self, Tox *m, int friendnumber, uint
if (tox_getname(m, friendnumber, name) == -1)
return;
name[TOXIC_MAX_NAME_LENGTH] = '\0'; /* enforce client max name length */
wprintw(self->window, "\nGroup chat invite from %s.\n", name);
int ngc = get_num_groupchats();

View File

@ -64,17 +64,19 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
if (length >= TOXIC_MAX_NAME_LENGTH) { /* length includes null byte */
string[TOXIC_MAX_NAME_LENGTH] = L'\0';
length = TOXIC_MAX_NAME_LENGTH+1;
length = TOXIC_MAX_NAME_LENGTH + 1;
tox_setfriendname(m, friendnumber, string, length);
}
/* Append friendnumber to duplicate nicks to guarantee uniqueness */
int n = get_friendnum(string);
if (n != friendnumber && n != -1) {
char n_buf[strlen(string)+4]; /* must have room for chars relative to MAX_FRIENDS_NUM */
char n_buf[strlen(string)+4]; /* must have room for friendnum chars relative to MAX_FRIENDS_NUM */
snprintf(n_buf, sizeof(n_buf), "%s%d", string, friendnumber);
strcpy(string, n_buf);
length = strlen(n_buf) + 1;
tox_setfriendname(m, friendnumber, string, length);
}
int i;