diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/toxic/windows.c | 20 | ||||
-rw-r--r-- | testing/toxic/windows.h | 5 |
2 files changed, 11 insertions, 14 deletions
diff --git a/testing/toxic/windows.c b/testing/toxic/windows.c index a8efa066..80d64287 100644 --- a/testing/toxic/windows.c +++ b/testing/toxic/windows.c | |||
@@ -6,7 +6,7 @@ | |||
6 | extern char *DATA_FILE; | 6 | extern char *DATA_FILE; |
7 | extern int store_data(Messenger *m, char *path); | 7 | extern int store_data(Messenger *m, char *path); |
8 | 8 | ||
9 | static ToxWindow windows[MAX_WINDOW_SLOTS]; | 9 | static ToxWindow windows[MAX_WINDOWS_NUM]; |
10 | static ToxWindow *active_window; | 10 | static ToxWindow *active_window; |
11 | static ToxWindow *prompt; | 11 | static ToxWindow *prompt; |
12 | static Messenger *m; | 12 | static Messenger *m; |
@@ -26,7 +26,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd | |||
26 | wprintw(prompt->window, "\nWith the message: %s\n", data); | 26 | wprintw(prompt->window, "\nWith the message: %s\n", data); |
27 | wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n); | 27 | wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n); |
28 | 28 | ||
29 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 29 | for (i = 0; i < MAX_WINDOWS_NUM; ++i) { |
30 | if (windows[i].onFriendRequest != NULL) | 30 | if (windows[i].onFriendRequest != NULL) |
31 | windows[i].onFriendRequest(&windows[i], public_key, data, length); | 31 | windows[i].onFriendRequest(&windows[i], public_key, data, length); |
32 | } | 32 | } |
@@ -36,7 +36,7 @@ void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length | |||
36 | { | 36 | { |
37 | int i; | 37 | int i; |
38 | 38 | ||
39 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 39 | for (i = 0; i < MAX_WINDOWS_NUM; ++i) { |
40 | if (windows[i].onMessage != NULL) | 40 | if (windows[i].onMessage != NULL) |
41 | windows[i].onMessage(&windows[i], m, friendnumber, string, length); | 41 | windows[i].onMessage(&windows[i], m, friendnumber, string, length); |
42 | } | 42 | } |
@@ -46,7 +46,7 @@ void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, | |||
46 | { | 46 | { |
47 | int i; | 47 | int i; |
48 | 48 | ||
49 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 49 | for (i = 0; i < MAX_WINDOWS_NUM; ++i) { |
50 | if (windows[i].onAction != NULL) | 50 | if (windows[i].onAction != NULL) |
51 | windows[i].onAction(&windows[i], m, friendnumber, string, length); | 51 | windows[i].onAction(&windows[i], m, friendnumber, string, length); |
52 | } | 52 | } |
@@ -57,7 +57,7 @@ void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t len | |||
57 | wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string); | 57 | wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string); |
58 | int i; | 58 | int i; |
59 | 59 | ||
60 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 60 | for (i = 0; i < MAX_WINDOWS_NUM; ++i) { |
61 | if (windows[i].onNickChange != NULL) | 61 | if (windows[i].onNickChange != NULL) |
62 | windows[i].onNickChange(&windows[i], friendnumber, string, length); | 62 | windows[i].onNickChange(&windows[i], friendnumber, string, length); |
63 | } | 63 | } |
@@ -68,7 +68,7 @@ void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t l | |||
68 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); | 68 | wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string); |
69 | int i; | 69 | int i; |
70 | 70 | ||
71 | for (i = 0; i < MAX_WINDOW_SLOTS; ++i) { | 71 | for (i = 0; i < MAX_WINDOWS_NUM; ++i) { |
72 | if (windows[i].onStatusChange != NULL) | 72 | if (windows[i].onStatusChange != NULL) |
73 | windows[i].onStatusChange(&windows[i], friendnumber, string, length); | 73 | windows[i].onStatusChange(&windows[i], friendnumber, string, length); |
74 | } | 74 | } |
@@ -90,7 +90,7 @@ int add_window(Messenger *m, ToxWindow w) | |||
90 | return -1; | 90 | return -1; |
91 | 91 | ||
92 | int i; | 92 | int i; |
93 | for(i = 0; i < MAX_WINDOW_SLOTS; i++) { | 93 | for(i = 0; i < MAX_WINDOWS_NUM; i++) { |
94 | if (windows[i].window) | 94 | if (windows[i].window) |
95 | continue; | 95 | continue; |
96 | 96 | ||
@@ -124,7 +124,7 @@ void del_window(ToxWindow *w) | |||
124 | /* Shows next window when tab or back-tab is pressed */ | 124 | /* Shows next window when tab or back-tab is pressed */ |
125 | void set_next_window(int ch) | 125 | void set_next_window(int ch) |
126 | { | 126 | { |
127 | ToxWindow *end = windows+MAX_WINDOW_SLOTS-1; | 127 | ToxWindow *end = windows+MAX_WINDOWS_NUM-1; |
128 | ToxWindow *inf = active_window; | 128 | ToxWindow *inf = active_window; |
129 | while(true) { | 129 | while(true) { |
130 | if (ch == '\t') { | 130 | if (ch == '\t') { |
@@ -146,7 +146,7 @@ void set_next_window(int ch) | |||
146 | 146 | ||
147 | void set_active_window(int index) | 147 | void set_active_window(int index) |
148 | { | 148 | { |
149 | if (index < 0 || index >= MAX_WINDOW_SLOTS) | 149 | if (index < 0 || index >= MAX_WINDOWS_NUM) |
150 | return; | 150 | return; |
151 | 151 | ||
152 | active_window = windows+index; | 152 | active_window = windows+index; |
@@ -187,7 +187,7 @@ static void draw_bar() | |||
187 | 187 | ||
188 | int i; | 188 | int i; |
189 | 189 | ||
190 | for (i = 0; i < (MAX_WINDOW_SLOTS); ++i) { | 190 | for (i = 0; i < (MAX_WINDOWS_NUM); ++i) { |
191 | if (windows[i].window) { | 191 | if (windows[i].window) { |
192 | if (windows+i == active_window) | 192 | if (windows+i == active_window) |
193 | attron(A_BOLD); | 193 | attron(A_BOLD); |
diff --git a/testing/toxic/windows.h b/testing/toxic/windows.h index 7b784699..be5557e9 100644 --- a/testing/toxic/windows.h +++ b/testing/toxic/windows.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <stdint.h> | 8 | #include <stdint.h> |
9 | #include <stdbool.h> | 9 | #include <stdbool.h> |
10 | #include "../../core/Messenger.h" | 10 | #include "../../core/Messenger.h" |
11 | #define TOXWINDOWS_MAX_NUM 32 | 11 | #define MAX_WINDOWS_NUM 32 |
12 | #define MAX_FRIENDS_NUM 100 | 12 | #define MAX_FRIENDS_NUM 100 |
13 | #define MAX_STR_SIZE 256 | 13 | #define MAX_STR_SIZE 256 |
14 | #define KEY_SIZE_BYTES 32 | 14 | #define KEY_SIZE_BYTES 32 |
@@ -16,9 +16,6 @@ | |||
16 | /* number of permanent default windows */ | 16 | /* number of permanent default windows */ |
17 | #define N_DEFAULT_WINS 3 | 17 | #define N_DEFAULT_WINS 3 |
18 | 18 | ||
19 | /* maximum window slots for WINDOW_STATUS array */ | ||
20 | #define MAX_WINDOW_SLOTS N_DEFAULT_WINS+MAX_FRIENDS_NUM | ||
21 | |||
22 | #ifndef TOXICVER | 19 | #ifndef TOXICVER |
23 | #define TOXICVER "NOVER" //Use the -D flag to set this | 20 | #define TOXICVER "NOVER" //Use the -D flag to set this |
24 | #endif | 21 | #endif |