summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/nTox.c30
-rw-r--r--testing/toxic/chat.c3
-rw-r--r--testing/toxic/friendlist.c1
-rw-r--r--testing/toxic/main.c23
-rw-r--r--testing/toxic/prompt.c2
5 files changed, 21 insertions, 38 deletions
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)
71void new_lines(char *line) 71void 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
338void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) 338void 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
347void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) 347void 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
356void load_key() 356void 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
108static void chat_onDraw(ToxWindow* self) { 108static 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
115static void friendlist_onDraw(ToxWindow* self) { 115static 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 */
289void 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
303int main(int argc, char* argv[]) { 283int 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
289static void prompt_onDraw(ToxWindow* self) { 290static 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);