mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
commit
9160a12ee1
|
@ -14,8 +14,8 @@ if(WIN32)
|
||||||
testing/Messenger_test.c)
|
testing/Messenger_test.c)
|
||||||
else()
|
else()
|
||||||
set(test_sources
|
set(test_sources
|
||||||
#testing/nTox.c)
|
testing/nTox.c)
|
||||||
testing/Messenger_test.c)
|
#testing/Messenger_test.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${exe_name}
|
add_executable(${exe_name}
|
||||||
|
|
|
@ -30,6 +30,9 @@ unsigned char * hex_string_to_bin(char hex_string[])
|
||||||
void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||||
{
|
{
|
||||||
if (line[0] == '/') {
|
if (line[0] == '/') {
|
||||||
|
char command[STRING_LENGTH + 2] = "> ";
|
||||||
|
strcat(command, line);
|
||||||
|
new_lines(command);
|
||||||
if (line[1] == 'f') { // add friend command: /f ID
|
if (line[1] == 'f') { // add friend command: /f ID
|
||||||
int i;
|
int i;
|
||||||
char temp_id[128];
|
char temp_id[128];
|
||||||
|
@ -38,7 +41,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||||
}
|
}
|
||||||
int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
|
int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
|
||||||
char numstring[100];
|
char numstring[100];
|
||||||
sprintf(numstring, "%d", num);
|
sprintf(numstring, "Friend added, number: %d", num);
|
||||||
new_lines(numstring);
|
new_lines(numstring);
|
||||||
do_refresh();
|
do_refresh();
|
||||||
} else if (line[1] == 'd') {
|
} else if (line[1] == 'd') {
|
||||||
|
@ -62,9 +65,6 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||||
int num = atoi(numstring);
|
int num = atoi(numstring);
|
||||||
m_sendmessage(num, (uint8_t*) message, sizeof((uint8_t*)message));
|
m_sendmessage(num, (uint8_t*) message, sizeof((uint8_t*)message));
|
||||||
}
|
}
|
||||||
char command[STRING_LENGTH + 2] = "> ";
|
|
||||||
strcat(command, line);
|
|
||||||
new_lines(command);
|
|
||||||
} else {
|
} else {
|
||||||
//new_lines(line);
|
//new_lines(line);
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,17 @@ void print_request(uint8_t * public_key, uint8_t * data, uint16_t length)
|
||||||
{
|
{
|
||||||
new_lines("Friend request accepted.");
|
new_lines("Friend request accepted.");
|
||||||
do_refresh();
|
do_refresh();
|
||||||
m_addfriend_norequest(public_key);
|
int num = m_addfriend_norequest(public_key);
|
||||||
|
char numchar[10];
|
||||||
|
sprintf(numchar, "Friend added, number: %d", num);
|
||||||
|
new_lines(numchar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void print_message(int friendnumber, uint8_t * string, uint16_t length)
|
void print_message(int friendnumber, uint8_t * string, uint16_t length)
|
||||||
{
|
{
|
||||||
new_lines("Message received");
|
char msg[100+length];
|
||||||
do_refresh();
|
sprintf(msg, "Message [%d]: %s", friendnumber, string);
|
||||||
m_sendmessage(friendnumber, (uint8_t*)"Test1", 6);
|
new_lines(msg);
|
||||||
}
|
}
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -181,7 +184,7 @@ int main(int argc, char *argv[])
|
||||||
raw();
|
raw();
|
||||||
getmaxyx(stdscr,y,x);
|
getmaxyx(stdscr,y,x);
|
||||||
new_lines(idstring0);
|
new_lines(idstring0);
|
||||||
do_refresh();
|
new_lines("/f ID (to add friend), /m friendnumber message (to send message)");
|
||||||
strcpy(line, "");
|
strcpy(line, "");
|
||||||
IP_Port bootstrap_ip_port;
|
IP_Port bootstrap_ip_port;
|
||||||
bootstrap_ip_port.port = htons(atoi(argv[2]));
|
bootstrap_ip_port.port = htons(atoi(argv[2]));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user