summaryrefslogtreecommitdiff
path: root/testing/toxic/prompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/prompt.c')
-rw-r--r--testing/toxic/prompt.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index c0169c62..fb8a5090 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -11,11 +11,12 @@
11#include "../../core/network.h" 11#include "../../core/network.h"
12 12
13#include "windows.h" 13#include "windows.h"
14#include "prompt.h"
14 15
15uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX 16uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX
16uint8_t num_requests=0; // XXX 17uint8_t num_requests=0; // XXX
17 18
18extern void on_friendadded(int friendnumber); 19static friendAddedFn *on_friendadded;
19static char prompt_buf[MAX_STR_SIZE] = {0}; 20static char prompt_buf[MAX_STR_SIZE] = {0};
20static int prompt_buf_pos = 0; 21static int prompt_buf_pos = 0;
21 22
@@ -87,7 +88,7 @@ void cmd_accept(ToxWindow *self, Messenger *m, char **args)
87 wprintw(self->window, "Failed to add friend.\n"); 88 wprintw(self->window, "Failed to add friend.\n");
88 else { 89 else {
89 wprintw(self->window, "Friend accepted as: %d.\n", num); 90 wprintw(self->window, "Friend accepted as: %d.\n", num);
90 on_friendadded(num); 91 on_friendadded(m, num);
91 } 92 }
92} 93}
93 94
@@ -143,9 +144,15 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
143 case FAERR_UNKNOWN: 144 case FAERR_UNKNOWN:
144 wprintw(self->window, "Undefined error when adding friend.\n"); 145 wprintw(self->window, "Undefined error when adding friend.\n");
145 break; 146 break;
147 case FAERR_BADCHECKSUM:
148 wprintw(self->window, "Bad checksum in address.\n");
149 break;
150 case FAERR_SETNEWNOSPAM:
151 wprintw(self->window, "Nospam was different.\n");
152 break;
146 default: 153 default:
147 wprintw(self->window, "Friend added as %d.\n", num); 154 wprintw(self->window, "Friend added as %d.\n", num);
148 on_friendadded(num); 155 on_friendadded(m, num);
149 break; 156 break;
150 } 157 }
151} 158}
@@ -427,8 +434,9 @@ static void prompt_onInit(ToxWindow *self, Messenger *m)
427 wclrtoeol(self->window); 434 wclrtoeol(self->window);
428} 435}
429 436
430ToxWindow new_prompt() 437ToxWindow new_prompt(friendAddedFn *f)
431{ 438{
439 on_friendadded = f;
432 ToxWindow ret; 440 ToxWindow ret;
433 memset(&ret, 0, sizeof(ret)); 441 memset(&ret, 0, sizeof(ret));
434 ret.onKey = &prompt_onKey; 442 ret.onKey = &prompt_onKey;