diff options
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r-- | testing/toxic/main.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 162cce68..2922456e 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -53,8 +53,9 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length) | |||
53 | wprintw(prompt->window, "%02x", public_key[i] & 0xff); | 53 | wprintw(prompt->window, "%02x", public_key[i] & 0xff); |
54 | } | 54 | } |
55 | 55 | ||
56 | wprintw(prompt->window, "\n"); | 56 | wprintw(prompt->window, "\nWith the message: %s\n", data); |
57 | wprintw(prompt->window, "Use \"accept %d\" to accept it.\n", n); | 57 | wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n); |
58 | |||
58 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 59 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { |
59 | if (windows[i].onFriendRequest != NULL) | 60 | if (windows[i].onFriendRequest != NULL) |
60 | windows[i].onFriendRequest(&windows[i], public_key, data, length); | 61 | windows[i].onFriendRequest(&windows[i], public_key, data, length); |
@@ -63,7 +64,6 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length) | |||
63 | 64 | ||
64 | void on_message(int friendnumber, uint8_t *string, uint16_t length) | 65 | void on_message(int friendnumber, uint8_t *string, uint16_t length) |
65 | { | 66 | { |
66 | wprintw(prompt->window, "\n(message) %d: %s\n", friendnumber, string); | ||
67 | int i; | 67 | int i; |
68 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 68 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { |
69 | if (windows[i].onMessage != NULL) | 69 | if (windows[i].onMessage != NULL) |
@@ -71,6 +71,15 @@ void on_message(int friendnumber, uint8_t *string, uint16_t length) | |||
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | void on_action(int friendnumber, uint8_t *string, uint16_t length) | ||
75 | { | ||
76 | int i; | ||
77 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | ||
78 | if (windows[i].onAction != NULL) | ||
79 | windows[i].onAction(&windows[i], friendnumber, string, length); | ||
80 | } | ||
81 | } | ||
82 | |||
74 | void on_nickchange(int friendnumber, uint8_t *string, uint16_t length) | 83 | void on_nickchange(int friendnumber, uint8_t *string, uint16_t length) |
75 | { | 84 | { |
76 | wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string); | 85 | wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string); |
@@ -126,6 +135,7 @@ static void init_tox() | |||
126 | m_callback_friendmessage(on_message); | 135 | m_callback_friendmessage(on_message); |
127 | m_callback_namechange(on_nickchange); | 136 | m_callback_namechange(on_nickchange); |
128 | m_callback_statusmessage(on_statuschange); | 137 | m_callback_statusmessage(on_statuschange); |
138 | m_callback_action(on_action); | ||
129 | } | 139 | } |
130 | 140 | ||
131 | void init_window_status() | 141 | void init_window_status() |
@@ -281,13 +291,13 @@ static void draw_bar() | |||
281 | attron(A_BOLD); | 291 | attron(A_BOLD); |
282 | 292 | ||
283 | odd = (odd+1) % blinkrate; | 293 | odd = (odd+1) % blinkrate; |
284 | if (windows[i].blink && (odd < (blinkrate/2))) { | 294 | if (windows[i].blink && (odd < (blinkrate/2))) |
285 | attron(COLOR_PAIR(3)); | 295 | attron(COLOR_PAIR(3)); |
286 | } | 296 | |
287 | printw(" %s", windows[i].title); | 297 | printw(" %s", windows[i].title); |
288 | if (windows[i].blink && (odd < (blinkrate/2))) { | 298 | if (windows[i].blink && (odd < (blinkrate/2))) |
289 | attroff(COLOR_PAIR(3)); | 299 | attroff(COLOR_PAIR(3)); |
290 | } | 300 | |
291 | if (i == active_window) { | 301 | if (i == active_window) { |
292 | attroff(A_BOLD); | 302 | attroff(A_BOLD); |
293 | } | 303 | } |
@@ -317,7 +327,6 @@ void set_active_window(int ch) | |||
317 | i = (i + 1) % max; | 327 | i = (i + 1) % max; |
318 | if (f_inf++ > max) { // infinite loop check | 328 | if (f_inf++ > max) { // infinite loop check |
319 | endwin(); | 329 | endwin(); |
320 | clear(); | ||
321 | exit(2); | 330 | exit(2); |
322 | } | 331 | } |
323 | } | 332 | } |
@@ -332,7 +341,6 @@ void set_active_window(int ch) | |||
332 | if (--i < 0) i = max; | 341 | if (--i < 0) i = max; |
333 | if (f_inf++ > max) { | 342 | if (f_inf++ > max) { |
334 | endwin(); | 343 | endwin(); |
335 | clear(); | ||
336 | exit(2); | 344 | exit(2); |
337 | } | 345 | } |
338 | } | 346 | } |