diff --git a/.travis.yml b/.travis.yml
index 9de4e2823..ff1732a06 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,8 +15,8 @@ before_script:
- cd ..
# installing libconfig, needed for DHT_bootstrap_daemon
- sudo sed -i 's/precise/quantal/' /etc/apt/sources.list # needed for libconfig-dev
- - sudo apt-get update -qq
- - yes | sudo apt-get install libconfig-dev
+ - sudo apt-get update -q
+ - sudo apt-get -y install libconfig-dev
script:
- mkdir build && cd build
diff --git a/INSTALL.md b/INSTALL.md
index 8e67d848f..3459a5c79 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -5,8 +5,9 @@
Build dependencies:
```bash
-apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev
+apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall
```
+Note that `libconfig-dev` should be >= 1.4.
You should get and install [libsodium](https://github.com/jedisct1/libsodium):
```bash
@@ -15,7 +16,7 @@ cd libsodium
git checkout tags/0.4.2
./autogen.sh
./configure && make check
-sudo make install
+sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc
sudo ldconfig
```
@@ -68,7 +69,7 @@ You have to [modify your PATH environment variable](http://www.computerhope.com/
Then you should either clone this repo by using git, or just download a [zip of current Master branch](https://github.com/irungentoo/ProjectTox-Core/archive/master.zip) and extract it somewhere.
-After that you should get precompiled packages of libsodium from [here](https://download.libsodium.org/libsodium/releases/) and extract the archive into this repo's root. That is, `sodium` folder should be along with `core`, `testing` and other folders.
+After that you should get precompiled package of libsodium from [here](https://download.libsodium.org/libsodium/releases/libsodium-win32-0.4.2.tar.gz) and extract the archive into this repo's root. That is, `sodium` folder should be along with `core`, `testing` and other folders.
Navigate in `cmd` to this repo and run:
```cmd
diff --git a/README.md b/README.md
index b4381bc9f..8f903bc0a 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ With the rise of governmental monitoring programs, Tox aims to be an easy to use
+ Tox must use UDP simply because you can't hole punch with TCP. It's possible, but it doesn't work all the time.
+ Every peer is represented as a byte string (the public key of the peer [client id])
+ We're using torrent-style DHT so that peers can find the IP of the other peers when they have their ID.
-+ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto)
++ Once the client has the IP of that peer, they start initiating a secure connection with each other. (See [Crypto](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto))
+ When both peers are securely connect with the encryption, they can securely exchange messages, initiate a video chat, send files, etc.
+ Current build status: [](https://travis-ci.org/irungentoo/ProjectTox-Core)
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 6ddd5b9b1..420308d82 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -6,12 +6,12 @@ if(WIN32)
endif()
set(core_sources
- DHT.c
- network.c
- Lossless_UDP.c
- net_crypto.c
- friend_requests.c
- LAN_discovery.c
- Messenger.c)
+ DHT.c
+ network.c
+ Lossless_UDP.c
+ net_crypto.c
+ friend_requests.c
+ LAN_discovery.c
+ Messenger.c)
add_library(core ${core_sources})
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c
index eb1314d16..6be8328f5 100644
--- a/core/Lossless_UDP.c
+++ b/core/Lossless_UDP.c
@@ -308,12 +308,16 @@ IP_Port connection_ip(int connection_id)
/* returns the number of packets in the queue waiting to be successfully sent. */
uint32_t sendqueue(int connection_id)
{
+ if (connection_id < 0 || connection_id >= MAX_CONNECTIONS)
+ return 0;
return connections[connection_id].sendbuff_packetnum - connections[connection_id].successful_sent;
}
/* returns the number of packets in the queue waiting to be successfully read with read_packet(...) */
uint32_t recvqueue(int connection_id)
{
+ if (connection_id < 0 || connection_id >= MAX_CONNECTIONS)
+ return 0;
return connections[connection_id].recv_packetnum - connections[connection_id].successful_read;
}
@@ -321,6 +325,8 @@ uint32_t recvqueue(int connection_id)
return -1 if no packet in queue */
char id_packet(int connection_id)
{
+ if (connection_id < 0 || connection_id >= MAX_CONNECTIONS)
+ return -1;
if (recvqueue(connection_id) != 0 && connections[connection_id].status != 0)
return connections[connection_id].recvbuffer[connections[connection_id].successful_read % MAX_QUEUE_NUM].data[0];
return -1;
diff --git a/core/Messenger.c b/core/Messenger.c
index f77b4491a..272c5fa7a 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -71,6 +71,12 @@ int getfriend_id(uint8_t *client_id)
return -1;
}
+/* Returns number of friends */
+int getnumfriends()
+{
+ return numfriends;
+}
+
/* copies the public key associated to that friend id into client_id buffer.
make sure that client_id is of size CLIENT_ID_SIZE.
return 0 if success
@@ -234,6 +240,16 @@ int setname(uint8_t * name, uint16_t length)
return 0;
}
+/* get our nickname
+ put it in name
+ name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
+ 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.
diff --git a/core/Messenger.h b/core/Messenger.h
index 7263901c2..6ab501757 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -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.
diff --git a/core/network.c b/core/network.c
index aa16bda9d..a7a4efcd2 100644
--- a/core/network.c
+++ b/core/network.c
@@ -169,7 +169,7 @@ void shutdown_networking()
address should represent IPv4, IPv6 or a hostname
on success returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i
on failure returns -1 */
-int resolve_addr(char *address)
+int resolve_addr(const char *address)
{
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
@@ -178,7 +178,7 @@ int resolve_addr(char *address)
struct addrinfo *server = NULL;
- int success = getaddrinfo(address, "7", &hints, &server);
+ int success = getaddrinfo(address, "echo", &hints, &server);
if(success != 0)
return -1;
diff --git a/core/network.h b/core/network.h
index aaaaa4099..8af4b32f6 100644
--- a/core/network.h
+++ b/core/network.h
@@ -125,7 +125,7 @@ void shutdown_networking();
address should represent IPv4, IPv6 or a hostname
on success returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i
on failure returns -1 */
-int resolve_addr(char *address);
+int resolve_addr(const char *address);
#ifdef __cplusplus
}
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 19714e70b..befe22258 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -79,12 +79,20 @@ int main(int argc, char *argv[])
manage_keys();
printf("Public key: ");
uint32_t i;
+
+ FILE *file;
+ file = fopen("PUBLIC_ID.txt", "w");
+
for(i = 0; i < 32; i++)
{
if(self_public_key[i] < 16)
printf("0");
printf("%hhX",self_public_key[i]);
+ fprintf(file, "%hhX",self_public_key[i]);
}
+
+ fclose(file);
+
printf("\n");
printf("Port: %u\n", PORT);
//initialize networking
diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt
index 6aa4dbeef..57ba48415 100644
--- a/other/bootstrap_serverdaemon/CMakeLists.txt
+++ b/other/bootstrap_serverdaemon/CMakeLists.txt
@@ -4,7 +4,9 @@ project(DHT_bootstrap_daemon C)
set(exe_name DHT_bootstrap_daemon)
add_executable(${exe_name}
- DHT_bootstrap_daemon.c)
+ DHT_bootstrap_daemon.c)
+
+target_link_libraries(${exe_name}
+ config)
-target_link_libraries(${exe_name} config)
linkCoreLibraries(${exe_name})
diff --git a/other/cmake/DHT_bootstrap.cmake b/other/cmake/DHT_bootstrap.cmake
index e2b164bab..403522ab5 100644
--- a/other/cmake/DHT_bootstrap.cmake
+++ b/other/cmake/DHT_bootstrap.cmake
@@ -4,6 +4,7 @@ project(DHT_bootstrap C)
set(exe_name DHT_bootstrap)
add_executable(${exe_name}
- DHT_bootstrap.c ../testing/misc_tools.c)
+ DHT_bootstrap.c
+ ../testing/misc_tools.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
index 3085b0c5f..abbc278ee 100644
--- a/testing/CMakeLists.txt
+++ b/testing/CMakeLists.txt
@@ -8,8 +8,11 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DHT_test.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake)
+if(WIN32)
+ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake)
+endif()
+
if(NOT WIN32)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox.cmake)
-include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toxic.cmake)
-
+ add_subdirectory(toxic)
endif()
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 2e9c2ac27..a215463df 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -134,7 +134,9 @@ int main(int argc, char *argv[])
char temp_id[128];
printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n");
- scanf("%s", temp_id);
+ if(scanf("%s", temp_id) != 1)
+ exit(0);
+
DHT_addfriend(hex_string_to_bin(temp_id));
/* initialize networking */
diff --git a/testing/cmake/DHT_cryptosendfiletest.cmake b/testing/cmake/DHT_cryptosendfiletest.cmake
index c98a2bcd4..5470d02a0 100644
--- a/testing/cmake/DHT_cryptosendfiletest.cmake
+++ b/testing/cmake/DHT_cryptosendfiletest.cmake
@@ -4,6 +4,7 @@ project(DHT_cryptosendfiletest C)
set(exe_name DHT_cryptosendfiletest)
add_executable(${exe_name}
- DHT_cryptosendfiletest.c misc_tools.c)
+ DHT_cryptosendfiletest.c
+ misc_tools.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/DHT_sendfiletest.cmake b/testing/cmake/DHT_sendfiletest.cmake
index 937379146..298db46cd 100644
--- a/testing/cmake/DHT_sendfiletest.cmake
+++ b/testing/cmake/DHT_sendfiletest.cmake
@@ -4,6 +4,6 @@ project(DHT_sendfiletest C)
set(exe_name DHT_sendfiletest)
add_executable(${exe_name}
- DHT_sendfiletest.c)
+ DHT_sendfiletest.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/DHT_test.cmake b/testing/cmake/DHT_test.cmake
index 74fdf35d2..bb5bf05f7 100644
--- a/testing/cmake/DHT_test.cmake
+++ b/testing/cmake/DHT_test.cmake
@@ -4,6 +4,7 @@ project(DHT_test C)
set(exe_name DHT_test)
add_executable(${exe_name}
- DHT_test.c misc_tools.c)
+ DHT_test.c
+ misc_tools.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Lossless_UDP_testclient.cmake b/testing/cmake/Lossless_UDP_testclient.cmake
index e894d228a..5f6518072 100644
--- a/testing/cmake/Lossless_UDP_testclient.cmake
+++ b/testing/cmake/Lossless_UDP_testclient.cmake
@@ -4,6 +4,6 @@ project(Lossless_UDP_testclient C)
set(exe_name Lossless_UDP_testclient)
add_executable(${exe_name}
- Lossless_UDP_testclient.c)
+ Lossless_UDP_testclient.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Lossless_UDP_testserver.cmake b/testing/cmake/Lossless_UDP_testserver.cmake
index 04306c1a7..26f9302e8 100644
--- a/testing/cmake/Lossless_UDP_testserver.cmake
+++ b/testing/cmake/Lossless_UDP_testserver.cmake
@@ -4,6 +4,6 @@ project(Lossless_UDP_testserver C)
set(exe_name Lossless_UDP_testserver)
add_executable(${exe_name}
- Lossless_UDP_testserver.c)
+ Lossless_UDP_testserver.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/Messenger_test.cmake b/testing/cmake/Messenger_test.cmake
index b2f54d0a9..15fcd77b0 100644
--- a/testing/cmake/Messenger_test.cmake
+++ b/testing/cmake/Messenger_test.cmake
@@ -4,6 +4,6 @@ project(Messenger_test C)
set(exe_name Messenger_test)
add_executable(${exe_name}
- Messenger_test.c misc_tools.c)
+ Messenger_test.c misc_tools.c)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/nTox.cmake b/testing/cmake/nTox.cmake
index 4c6905e5b..44476b8f9 100644
--- a/testing/cmake/nTox.cmake
+++ b/testing/cmake/nTox.cmake
@@ -4,8 +4,9 @@ project(nTox C)
set(exe_name nTox)
add_executable(${exe_name}
- nTox.c misc_tools.c)
-
-target_link_libraries(${exe_name} ncurses)
+ nTox.c misc_tools.c)
+
+target_link_libraries(${exe_name}
+ ncurses)
linkCoreLibraries(${exe_name})
diff --git a/testing/cmake/nTox_win32.cmake b/testing/cmake/nTox_win32.cmake
new file mode 100644
index 000000000..5acfb4118
--- /dev/null
+++ b/testing/cmake/nTox_win32.cmake
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.6.0)
+project(nTox_win32 C)
+
+set(exe_name nTox_win32)
+
+add_executable(${exe_name}
+ nTox_win32.c misc_tools.c)
+
+linkCoreLibraries(${exe_name})
diff --git a/testing/nTox.c b/testing/nTox.c
index 960dfb279..9876f4ba8 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -20,10 +20,10 @@
* along with Tox. If not, see .
*
*/
-
#include "nTox.h"
#include "misc_tools.h"
+
#include
#include
#ifdef WIN32
@@ -50,6 +50,46 @@ void new_lines(char *line)
do_refresh();
}
+
+void print_friendlist()
+{
+ char name[MAX_NAME_LENGTH];
+ uint32_t i;
+
+ new_lines("[i] Friend List:");
+ for (i=0; i <= num_requests; i++) {
+ char fstring[128];
+
+ getname(i, (uint8_t*)name);
+ if (strlen(name) <= 0) {
+ sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i);
+ } else {
+ sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i);
+ }
+ new_lines(fstring);
+ }
+}
+
+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] == '/') {
@@ -88,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') {
@@ -104,6 +146,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
sprintf(numstring, "[i] changed nick to %s", (char*)name);
new_lines(numstring);
}
+ else if (line[1] == 'l') {
+ print_friendlist();
+ }
else if (line[1] == 's') {
uint8_t status[MAX_USERSTATUS_LENGTH];
int i = 0;
@@ -129,11 +174,20 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
do_refresh();
}
+
+ else if (line[1] == 'h') { //help
+ new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)");
+ new_lines("[i] /l list (list friends), /h for help, /n nick (to change nickname), /q (to quit)");
+ }
+
else if (line[1] == 'q') { //exit
endwin();
exit(EXIT_SUCCESS);
+ } else {
+ new_lines("[i] invalid command");
}
} else {
+ new_lines("[i] invalid command");
//new_lines(line);
}
}
@@ -224,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) {
@@ -313,7 +367,8 @@ int main(int argc, char *argv[])
raw();
getmaxyx(stdscr,y,x);
new_lines(idstring0);
- new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status), /n nick (to change nickname), /q (to quit)");
+ new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)");
+ new_lines("[i] /l list (list friends), /n nick (to change nickname), /q (to quit)");
strcpy(line, "");
IP_Port bootstrap_ip_port;
bootstrap_ip_port.port = htons(atoi(argv[2]));
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c
new file mode 100644
index 000000000..3a9caaf5e
--- /dev/null
+++ b/testing/nTox_win32.c
@@ -0,0 +1,323 @@
+/* nTox_win32.c
+ *
+ * Textual frontend for Tox - Windows version
+ *
+ * Copyright (C) 2013 Tox project All Rights Reserved.
+ *
+ * This file is part of Tox.
+ *
+ * Tox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tox. If not, see .
+ *
+ */
+
+#include "nTox_win32.h"
+#include "misc_tools.h"
+
+#include
+
+uint8_t pending_requests[256][CLIENT_ID_SIZE];
+uint8_t num_requests;
+
+char line[STRING_LENGTH];
+char users_id[200];
+
+void do_header()
+{
+ system("cls");
+ printf(users_id);
+ printf("\n---------------------------------");
+ printf("\n[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status), /n nick (to change nickname), /l (lists friends), /d friendnumber (deletes friend), /q (to quit), /r (reset screen)");
+ printf("\n---------------------------------");
+}
+
+void print_request(uint8_t *public_key, uint8_t *data, uint16_t length)
+{
+ printf("\n\n[i] received friend request with message\n");
+ printf((char *)data);
+ char numchar[100];
+ sprintf(numchar, "\n\n[i] accept request with /a %u\n\n", num_requests);
+ printf(numchar);
+ memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE);
+ ++num_requests;
+}
+
+void print_message(int friendnumber, uint8_t * string, uint16_t length)
+{
+ char name[MAX_NAME_LENGTH];
+ getname(friendnumber, (uint8_t*)name);
+ char msg[100+length+strlen(name)+1];
+ time_t rawtime;
+ struct tm * timeinfo;
+ time (&rawtime);
+ timeinfo = localtime (&rawtime);
+ char* temp = asctime(timeinfo);
+ size_t len = strlen(temp);
+ temp[len-1]='\0';
+ sprintf(msg, "\n[%d] %s <%s> %s\n\n", friendnumber, temp, name, string); // timestamp
+ printf(msg);
+}
+
+void print_nickchange(int friendnumber, uint8_t *string, uint16_t length)
+{
+ char name[MAX_NAME_LENGTH];
+ getname(friendnumber, (uint8_t*)name);
+ char msg[100+length];
+ sprintf(msg, "\n\n[i] [%d] %s is now known as %s.\n\n", friendnumber, name, string);
+ printf(msg);
+}
+
+void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) {
+ char name[MAX_NAME_LENGTH];
+ getname(friendnumber, (uint8_t*)name);
+ char msg[100+length+strlen(name)+1];
+ sprintf(msg, "\n\n[i] [%d] %s's status changed to %s.\n", friendnumber, name, string);
+ printf(msg);
+}
+
+void load_key()
+{
+ FILE *data_file = NULL;
+
+ if ((data_file = fopen("data", "r"))) {
+ fseek(data_file, 0, SEEK_END);
+ int size = ftell(data_file);
+ fseek(data_file, 0, SEEK_SET);
+ uint8_t data[size];
+
+ if(fread(data, sizeof(uint8_t), size, data_file) != size) {
+ printf("\n[i] Could not read the data file. Exiting.");
+ exit(1);
+ }
+
+ Messenger_load(data, size);
+ } else {
+ int size = Messenger_size();
+ uint8_t data[size];
+ Messenger_save(data);
+ data_file = fopen("data", "w");
+
+ if(fwrite(data, sizeof(uint8_t), size, data_file) != size) {
+ printf("\n[i] Could not write data to file. Exiting.");
+ exit(1);
+ }
+ }
+
+ fclose(data_file);
+}
+
+void line_eval(char* line)
+{
+ if(line[0] == '/') {
+ /* Add friend */
+ if(line[1] == 'f') {
+ int i;
+ char temp_id[128];
+ for (i=0; i<128; i++)
+ temp_id[i] = line[i+3];
+ int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
+ char numstring[100];
+ sprintf(numstring, "\n[i] added friend %d\n\n", num);
+ printf(numstring);
+ }
+
+ else if (line[1] == 'r') {
+ do_header();
+ printf("\n\n");
+ }
+
+ else if (line[1] == 'l') {
+ printf("\n[i] Friend List | Total: %d\n\n", getnumfriends());
+
+ int i;
+
+ for (i=0; i < getnumfriends(); i++) {
+ char name[MAX_NAME_LENGTH];
+ getname(i, (uint8_t*)name);
+ printf("[%d] %s\n\n", i, (uint8_t*)name);
+ }
+ }
+
+ else if (line[1] == 'd') {
+ size_t len = strlen(line);
+ char numstring[len-3];
+ int i;
+ for (i=0; i\n", argv[0]);
+ exit(0);
+ }
+
+ if (initMessenger() == -1) {
+ printf("initMessenger failed");
+ exit(0);
+ }
+
+ if (argc > 4) {
+ if(strncmp(argv[4], "nokey", 6) < 0) {
+ }
+ } else {
+ load_key();
+ }
+
+ m_callback_friendrequest(print_request);
+ m_callback_friendmessage(print_message);
+ m_callback_namechange(print_nickchange);
+ m_callback_userstatus(print_statuschange);
+
+ char idstring1[32][5];
+ char idstring2[32][5];
+ uint32_t i;
+ for(i = 0; i < 32; i++)
+ {
+ if(self_public_key[i] < 16)
+ strcpy(idstring1[i],"0");
+ else
+ strcpy(idstring1[i], "");
+ sprintf(idstring2[i], "%hhX",self_public_key[i]);
+ }
+ strcpy(users_id,"[i] your ID: ");
+ for (i=0; i<32; i++) {
+ strcat(users_id,idstring1[i]);
+ strcat(users_id,idstring2[i]);
+ }
+
+ do_header();
+
+ IP_Port bootstrap_ip_port;
+ bootstrap_ip_port.port = htons(atoi(argv[2]));
+ int resolved_address = resolve_addr(argv[1]);
+ if (resolved_address != -1)
+ bootstrap_ip_port.ip.i = resolved_address;
+ else
+ exit(1);
+
+ DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
+
+ int c;
+ int on = 0;
+
+ _beginthread(get_input, 0, NULL);
+
+ while(1) {
+ if (on == 1 && DHT_isconnected() == -1) {
+ printf("\n---------------------------------");
+ printf("\n[i] Disconnected from the DHT");
+ printf("\n---------------------------------\n\n");
+ on = 0;
+ }
+
+ if (on == 0 && DHT_isconnected()) {
+ printf("\n[i] Connected to DHT");
+ printf("\n---------------------------------\n\n");
+ on = 1;
+ }
+
+ doMessenger();
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/testing/nTox_win32.h b/testing/nTox_win32.h
new file mode 100644
index 000000000..7861be1c1
--- /dev/null
+++ b/testing/nTox_win32.h
@@ -0,0 +1,31 @@
+/* nTox_win32.h
+ *
+ * Textual frontend for Tox - Windows version
+ *
+ * Copyright (C) 2013 Tox project All Rights Reserved.
+ *
+ * This file is part of Tox.
+ *
+ * Tox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tox. If not, see .
+ */
+
+#ifndef NTOX_WIN32_H
+#define NTOX_WIN32_H
+
+#include "../core/Messenger.h"
+#include "../core/network.h"
+
+#define STRING_LENGTH 256
+
+#endif
\ No newline at end of file
diff --git a/testing/cmake/toxic.cmake b/testing/toxic/CMakeLists.txt
similarity index 52%
rename from testing/cmake/toxic.cmake
rename to testing/toxic/CMakeLists.txt
index 494dea90b..4f9785d53 100644
--- a/testing/cmake/toxic.cmake
+++ b/testing/toxic/CMakeLists.txt
@@ -1,11 +1,13 @@
cmake_minimum_required(VERSION 2.6.0)
project(toxic C)
-set(exe_name toxic/toxic)
+set(exe_name toxic)
add_executable(${exe_name}
- toxic/main.c toxic/prompt.c)
-
-target_link_libraries(${exe_name} curses)
+ main.c
+ prompt.c)
+
+target_link_libraries(${exe_name}
+ curses)
linkCoreLibraries(${exe_name})