mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge branch 'master' of https://github.com/blackwolf12333/ProjectTox-Core into blackwolf12333-master
Also fixed his pull request.
This commit is contained in:
commit
87388b302e
|
@ -240,6 +240,15 @@ int setname(uint8_t * name, uint16_t length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* get our nickname
|
||||
put it in name
|
||||
return the length of the name */
|
||||
uint16_t getself_name(uint8_t *name)
|
||||
{
|
||||
memcpy(name, self_name, self_name_length);
|
||||
return self_name_length;
|
||||
}
|
||||
|
||||
/* get name of friendnumber
|
||||
put it in name
|
||||
name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
|
||||
|
|
|
@ -92,6 +92,11 @@ int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length);
|
|||
return -1 if failure */
|
||||
int setname(uint8_t *name, uint16_t length);
|
||||
|
||||
/* get our nickname
|
||||
put it in name
|
||||
return the length of the name*/
|
||||
uint16_t getself_name(uint8_t *name);
|
||||
|
||||
/* get name of friendnumber
|
||||
put it in name
|
||||
name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
||||
|
|
|
@ -50,6 +50,7 @@ void new_lines(char *line)
|
|||
do_refresh();
|
||||
}
|
||||
|
||||
|
||||
void print_friendlist()
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
|
@ -69,6 +70,26 @@ void print_friendlist()
|
|||
}
|
||||
}
|
||||
|
||||
char *format_message(char *message, int friendnum)
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
if(friendnum != -1) {
|
||||
getname(friendnum, (uint8_t*)name);
|
||||
} else {
|
||||
getself_name((uint8_t*)name);
|
||||
}
|
||||
char *msg = malloc(100+strlen(message)+strlen(name)+1);
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
time ( &rawtime );
|
||||
timeinfo = localtime ( &rawtime );
|
||||
char* time = asctime(timeinfo);
|
||||
size_t len = strlen(time);
|
||||
time[len-1]='\0';
|
||||
sprintf(msg, "[%d] %s <%s> %s", friendnum, time, name, message); // timestamp
|
||||
return msg;
|
||||
}
|
||||
|
||||
void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||
{
|
||||
if (line[0] == '/') {
|
||||
|
@ -107,6 +128,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
|||
int num = atoi(numstring);
|
||||
if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) {
|
||||
new_lines("[i] could not send message");
|
||||
} else {
|
||||
new_lines(format_message(message, -1));
|
||||
}
|
||||
}
|
||||
else if (line[1] == 'n') {
|
||||
|
@ -255,7 +278,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
|
|||
size_t len = strlen(temp);
|
||||
temp[len-1]='\0';
|
||||
sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp
|
||||
new_lines(msg);
|
||||
new_lines(format_message((char*)string, friendnumber));
|
||||
}
|
||||
|
||||
void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user