diff options
author | Astonex <softukitu@gmail.com> | 2013-08-03 14:57:42 +0100 |
---|---|---|
committer | Astonex <softukitu@gmail.com> | 2013-08-03 14:57:42 +0100 |
commit | da8996dbdd1fd8aef24d10bdf80894260a4560a3 (patch) | |
tree | 9f6b2edd3a8033d9e73356b23e3b81df254bb2b7 | |
parent | fcad4d0a5a3b5ed87032e21938b709bb98c2b0a4 (diff) | |
parent | 8cb960e785166a26f2cbcaf9daba6b29b2894305 (diff) |
Merge branch 'master' of git://github.com/irungentoo/ProjectTox-Core
-rwxr-xr-x | CMakeLists.txt | 4 | ||||
-rw-r--r-- | INSTALL.md | 22 | ||||
-rw-r--r-- | testing/nTox.c | 30 | ||||
-rw-r--r-- | testing/toxic/chat.c | 3 | ||||
-rw-r--r-- | testing/toxic/friendlist.c | 1 | ||||
-rw-r--r-- | testing/toxic/main.c | 23 | ||||
-rw-r--r-- | testing/toxic/prompt.c | 2 |
7 files changed, 47 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bf709e72..ed934c01 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 2.6.0) | |||
2 | 2 | ||
3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | 3 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
4 | 4 | ||
5 | if(UNIX) | ||
6 | find_package(Curses REQUIRED) | ||
7 | endif() | ||
8 | |||
5 | if(NOT WIN32) | 9 | if(NOT WIN32) |
6 | option(USE_NACL "Use NaCl library instead of libsodium") | 10 | option(USE_NACL "Use NaCl library instead of libsodium") |
7 | endif() | 11 | endif() |
@@ -18,6 +18,14 @@ Build dependencies: | |||
18 | ```bash | 18 | ```bash |
19 | apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall | 19 | apt-get install build-essential libtool autotools-dev automake libconfig-dev ncurses-dev cmake checkinstall |
20 | ``` | 20 | ``` |
21 | |||
22 | On Fedora: | ||
23 | |||
24 | ```bash | ||
25 | yum groupinstall "Development Tools" | ||
26 | yum install libtool autoconf automake libconfig-devel ncurses-devel cmake | ||
27 | ``` | ||
28 | |||
21 | Note that `libconfig-dev` should be >= 1.4. | 29 | Note that `libconfig-dev` should be >= 1.4. |
22 | 30 | ||
23 | You should get and install [libsodium](https://github.com/jedisct1/libsodium): | 31 | You should get and install [libsodium](https://github.com/jedisct1/libsodium): |
@@ -31,6 +39,20 @@ sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc | |||
31 | sudo ldconfig | 39 | sudo ldconfig |
32 | ``` | 40 | ``` |
33 | 41 | ||
42 | Or if checkinstall is not easily available for your distribution (e.g. Fedora), | ||
43 | this will install the libs to /usr/local/lib and the headers to /usr/local/include: | ||
44 | |||
45 | ```bash | ||
46 | git clone git://github.com/jedisct1/libsodium.git | ||
47 | cd libsodium | ||
48 | git checkout tags/0.4.2 | ||
49 | ./autogen.sh | ||
50 | ./configure | ||
51 | make check | ||
52 | sudo make install | ||
53 | ``` | ||
54 | |||
55 | |||
34 | Then clone this repo and generate makefile: | 56 | Then clone this repo and generate makefile: |
35 | ```bash | 57 | ```bash |
36 | git clone git://github.com/irungentoo/ProjectTox-Core.git | 58 | git clone git://github.com/irungentoo/ProjectTox-Core.git |
diff --git a/testing/nTox.c b/testing/nTox.c index 24d40ead..13db58d7 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | #include "nTox.h" | 23 | #include "nTox.h" |
24 | #include "misc_tools.h" | 24 | #include "misc_tools.h" |
@@ -54,7 +54,7 @@ void get_id(char *data) | |||
54 | { | 54 | { |
55 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | 55 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) |
56 | strcpy(idstring1[i],"0"); | 56 | strcpy(idstring1[i],"0"); |
57 | else | 57 | else |
58 | strcpy(idstring1[i], ""); | 58 | strcpy(idstring1[i], ""); |
59 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | 59 | sprintf(idstring2[i], "%hhX",self_public_key[i]); |
60 | } | 60 | } |
@@ -71,9 +71,9 @@ void get_id(char *data) | |||
71 | void new_lines(char *line) | 71 | void new_lines(char *line) |
72 | { | 72 | { |
73 | int i = 0; | 73 | int i = 0; |
74 | for (i = HISTORY-1; i > 0; i--) | 74 | for (i = HISTORY-1; i > 0; i--) |
75 | strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); | 75 | strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); |
76 | 76 | ||
77 | strncpy(lines[0], line, STRING_LENGTH - 1); | 77 | strncpy(lines[0], line, STRING_LENGTH - 1); |
78 | do_refresh(); | 78 | do_refresh(); |
79 | } | 79 | } |
@@ -133,7 +133,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
133 | if (inpt_command == 'f') { // add friend command: /f ID | 133 | if (inpt_command == 'f') { // add friend command: /f ID |
134 | int i; | 134 | int i; |
135 | char temp_id[128]; | 135 | char temp_id[128]; |
136 | for (i = 0; i < 128; i++) | 136 | for (i = 0; i < 128; i++) |
137 | temp_id[i] = line[i+prompt_offset]; | 137 | temp_id[i] = line[i+prompt_offset]; |
138 | 138 | ||
139 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); | 139 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); |
@@ -166,8 +166,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
166 | } | 166 | } |
167 | else if (inpt_command == 'm') { //message command: /m friendnumber messsage | 167 | else if (inpt_command == 'm') { //message command: /m friendnumber messsage |
168 | size_t len = strlen(line); | 168 | size_t len = strlen(line); |
169 | if(len < 3) | 169 | if(len < 3) |
170 | return; | 170 | return; |
171 | 171 | ||
172 | char numstring[len-3]; | 172 | char numstring[len-3]; |
173 | char message[len-3]; | 173 | char message[len-3]; |
@@ -248,7 +248,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
248 | else if (inpt_command == 'q') { //exit | 248 | else if (inpt_command == 'q') { //exit |
249 | endwin(); | 249 | endwin(); |
250 | exit(EXIT_SUCCESS); | 250 | exit(EXIT_SUCCESS); |
251 | } else { | 251 | } else { |
252 | new_lines("[i] invalid command"); | 252 | new_lines("[i] invalid command"); |
253 | } | 253 | } |
254 | } else { | 254 | } else { |
@@ -335,7 +335,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length) | |||
335 | new_lines(format_message((char*)string, friendnumber)); | 335 | new_lines(format_message((char*)string, friendnumber)); |
336 | } | 336 | } |
337 | 337 | ||
338 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | 338 | void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) |
339 | { | 339 | { |
340 | char name[MAX_NAME_LENGTH]; | 340 | char name[MAX_NAME_LENGTH]; |
341 | getname(friendnumber, (uint8_t*)name); | 341 | getname(friendnumber, (uint8_t*)name); |
@@ -344,7 +344,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) | |||
344 | new_lines(msg); | 344 | new_lines(msg); |
345 | } | 345 | } |
346 | 346 | ||
347 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) | 347 | void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) |
348 | { | 348 | { |
349 | char name[MAX_NAME_LENGTH]; | 349 | char name[MAX_NAME_LENGTH]; |
350 | getname(friendnumber, (uint8_t*)name); | 350 | getname(friendnumber, (uint8_t*)name); |
@@ -353,7 +353,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) | |||
353 | new_lines(msg); | 353 | new_lines(msg); |
354 | } | 354 | } |
355 | 355 | ||
356 | void load_key() | 356 | void load_key() |
357 | { | 357 | { |
358 | FILE *data_file = NULL; | 358 | FILE *data_file = NULL; |
359 | data_file = fopen("data","r"); | 359 | data_file = fopen("data","r"); |
@@ -368,7 +368,7 @@ void load_key() | |||
368 | exit(1); | 368 | exit(1); |
369 | } | 369 | } |
370 | Messenger_load(data, size); | 370 | Messenger_load(data, size); |
371 | } else { | 371 | } else { |
372 | //else save new keys | 372 | //else save new keys |
373 | int size = Messenger_size(); | 373 | int size = Messenger_size(); |
374 | uint8_t data[size]; | 374 | uint8_t data[size]; |
@@ -418,9 +418,9 @@ int main(int argc, char *argv[]) | |||
418 | int resolved_address = resolve_addr(argv[1]); | 418 | int resolved_address = resolve_addr(argv[1]); |
419 | if (resolved_address != 0) | 419 | if (resolved_address != 0) |
420 | bootstrap_ip_port.ip.i = resolved_address; | 420 | bootstrap_ip_port.ip.i = resolved_address; |
421 | else | 421 | else |
422 | exit(1); | 422 | exit(1); |
423 | 423 | ||
424 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); | 424 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); |
425 | nodelay(stdscr, TRUE); | 425 | nodelay(stdscr, TRUE); |
426 | while(true) { | 426 | while(true) { |
@@ -441,7 +441,7 @@ int main(int argc, char *argv[]) | |||
441 | if (c == '\n') { | 441 | if (c == '\n') { |
442 | line_eval(lines, line); | 442 | line_eval(lines, line); |
443 | strcpy(line, ""); | 443 | strcpy(line, ""); |
444 | } else if (c == 127) { | 444 | } else if (c == 8 || c == 127) { |
445 | line[strlen(line)-1] = '\0'; | 445 | line[strlen(line)-1] = '\0'; |
446 | } else if (isalnum(c) || ispunct(c) || c == ' ') { | 446 | } else if (isalnum(c) || ispunct(c) || c == ' ') { |
447 | strcpy(line, appender(line, (char) c)); | 447 | strcpy(line, appender(line, (char) c)); |
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 854d3817..1bfd94f5 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -106,6 +106,7 @@ static void chat_onKey(ToxWindow* self, int key) { | |||
106 | } | 106 | } |
107 | 107 | ||
108 | static void chat_onDraw(ToxWindow* self) { | 108 | static void chat_onDraw(ToxWindow* self) { |
109 | curs_set(1); | ||
109 | int x, y; | 110 | int x, y; |
110 | ChatContext* ctx = (ChatContext*) self->x; | 111 | ChatContext* ctx = (ChatContext*) self->x; |
111 | 112 | ||
@@ -117,7 +118,7 @@ static void chat_onDraw(ToxWindow* self) { | |||
117 | 118 | ||
118 | wclear(ctx->linewin); | 119 | wclear(ctx->linewin); |
119 | mvwhline(ctx->linewin, 0, 0, '_', COLS); | 120 | mvwhline(ctx->linewin, 0, 0, '_', COLS); |
120 | mvwprintw(ctx->linewin, 1, 0, "%s\n", ctx->line); | 121 | mvwprintw(self->window, y-1, 0, "%s\n", ctx->line); |
121 | 122 | ||
122 | wrefresh(self->window); | 123 | wrefresh(self->window); |
123 | } | 124 | } |
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c index f9a413f9..b4b619a2 100644 --- a/testing/toxic/friendlist.c +++ b/testing/toxic/friendlist.c | |||
@@ -113,6 +113,7 @@ static void friendlist_onKey(ToxWindow* self, int key) { | |||
113 | } | 113 | } |
114 | 114 | ||
115 | static void friendlist_onDraw(ToxWindow* self) { | 115 | static void friendlist_onDraw(ToxWindow* self) { |
116 | curs_set(0); | ||
116 | size_t i; | 117 | size_t i; |
117 | 118 | ||
118 | wclear(self->window); | 119 | wclear(self->window); |
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index c596b708..bcfc487f 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -280,26 +280,6 @@ void prepare_window(WINDOW* w) { | |||
280 | wresize(w, LINES-2, COLS); | 280 | wresize(w, LINES-2, COLS); |
281 | } | 281 | } |
282 | 282 | ||
283 | /* | ||
284 | * Draws cursor relative to input on prompt window. | ||
285 | * Removes cursor on friends window and chat windows. | ||
286 | * | ||
287 | * TODO: Make it work for chat windows | ||
288 | */ | ||
289 | void position_cursor(WINDOW* w, char* title) | ||
290 | { | ||
291 | curs_set(1); | ||
292 | if (strcmp(title, "[prompt]") == 0) { // main/prompt window | ||
293 | int x, y; | ||
294 | getyx(w, y, x); | ||
295 | move(y, x); | ||
296 | } | ||
297 | else if (strcmp(title, "[friends]") == 0) // friends window | ||
298 | curs_set(0); | ||
299 | else // any other window (i.e chat) | ||
300 | curs_set(0); | ||
301 | } | ||
302 | |||
303 | int main(int argc, char* argv[]) { | 283 | int main(int argc, char* argv[]) { |
304 | int ch; | 284 | int ch; |
305 | ToxWindow* a; | 285 | ToxWindow* a; |
@@ -317,9 +297,8 @@ int main(int argc, char* argv[]) { | |||
317 | a = &windows[w_active]; | 297 | a = &windows[w_active]; |
318 | prepare_window(a->window); | 298 | prepare_window(a->window); |
319 | a->blink = false; | 299 | a->blink = false; |
320 | a->onDraw(a); | ||
321 | draw_bar(); | 300 | draw_bar(); |
322 | position_cursor(a->window, a->title); | 301 | a->onDraw(a); |
323 | 302 | ||
324 | // Handle input. | 303 | // Handle input. |
325 | ch = getch(); | 304 | ch = getch(); |
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index b0f83811..1db60883 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c | |||
@@ -140,6 +140,7 @@ static void execute(ToxWindow* self, char* cmd) { | |||
140 | break; | 140 | break; |
141 | case -2: | 141 | case -2: |
142 | wprintw(self->window, "Please add a message to your request.\n"); | 142 | wprintw(self->window, "Please add a message to your request.\n"); |
143 | break; | ||
143 | case -3: | 144 | case -3: |
144 | wprintw(self->window, "That appears to be your own ID.\n"); | 145 | wprintw(self->window, "That appears to be your own ID.\n"); |
145 | break; | 146 | break; |
@@ -287,6 +288,7 @@ static void prompt_onKey(ToxWindow* self, int key) { | |||
287 | } | 288 | } |
288 | 289 | ||
289 | static void prompt_onDraw(ToxWindow* self) { | 290 | static void prompt_onDraw(ToxWindow* self) { |
291 | curs_set(1); | ||
290 | int x, y; | 292 | int x, y; |
291 | 293 | ||
292 | getyx(self->window, y, x); | 294 | getyx(self->window, y, x); |