summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/toxic/chat.c5
-rw-r--r--testing/toxic/chat.h3
-rw-r--r--testing/toxic/friendlist.c13
-rw-r--r--testing/toxic/friendlist.h6
-rw-r--r--testing/toxic/windows.c2
-rw-r--r--testing/toxic/windows.h3
6 files changed, 12 insertions, 20 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 6811569b..e4da9484 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -26,8 +26,6 @@ typedef struct {
26 WINDOW* linewin; 26 WINDOW* linewin;
27} ChatContext; 27} ChatContext;
28 28
29static delWindowFn *del_window;
30
31void print_help(ChatContext *self); 29void print_help(ChatContext *self);
32void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd); 30void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd);
33 31
@@ -370,9 +368,8 @@ void print_help(ChatContext *self)
370 wattroff(self->history, COLOR_PAIR(2)); 368 wattroff(self->history, COLOR_PAIR(2));
371} 369}
372 370
373ToxWindow new_chat(Messenger *m, int friendnum, delWindowFn *f) 371ToxWindow new_chat(Messenger *m, int friendnum)
374{ 372{
375 del_window = f;
376 ToxWindow ret; 373 ToxWindow ret;
377 memset(&ret, 0, sizeof(ret)); 374 memset(&ret, 0, sizeof(ret));
378 375
diff --git a/testing/toxic/chat.h b/testing/toxic/chat.h
index dcd5b3ba..7599d462 100644
--- a/testing/toxic/chat.h
+++ b/testing/toxic/chat.h
@@ -1,7 +1,6 @@
1#ifndef CHAT_H_6489PZ13 1#ifndef CHAT_H_6489PZ13
2#define CHAT_H_6489PZ13 2#define CHAT_H_6489PZ13
3 3
4typedef void (delWindowFn)(ToxWindow *w, int f_num); 4ToxWindow new_chat(Messenger *m, int friendnum);
5ToxWindow new_chat(Messenger *m, int friendnum, delWindowFn f);
6 5
7#endif /* end of include guard: CHAT_H_6489PZ13 */ 6#endif /* end of include guard: CHAT_H_6489PZ13 */
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index 5b79fdef..e7504fbf 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -10,11 +10,9 @@
10#include "../../core/Messenger.h" 10#include "../../core/Messenger.h"
11#include "../../core/network.h" 11#include "../../core/network.h"
12 12
13#include "windows.h"
13#include "friendlist.h" 14#include "friendlist.h"
14 15
15static delWindowFn *del_window;
16static setActiveWindowFn *set_active_window;
17static addWindowFn *add_window;
18static char * WINDOW_STATUS; 16static char * WINDOW_STATUS;
19 17
20typedef struct { 18typedef struct {
@@ -53,7 +51,7 @@ void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str,
53 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) { 51 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
54 if (WINDOW_STATUS[i] == -1) { 52 if (WINDOW_STATUS[i] == -1) {
55 WINDOW_STATUS[i] = num; 53 WINDOW_STATUS[i] = num;
56 add_window(m, new_chat(m, num, del_window), i); 54 add_window(m, new_chat(m, num), i);
57 break; 55 break;
58 } 56 }
59 } 57 }
@@ -119,7 +117,7 @@ static void friendlist_onKey(ToxWindow *self, Messenger *m, int key)
119 if (WINDOW_STATUS[i] == -1) { 117 if (WINDOW_STATUS[i] == -1) {
120 WINDOW_STATUS[i] = num_selected; 118 WINDOW_STATUS[i] = num_selected;
121 friends[num_selected].chatwin = num_selected; 119 friends[num_selected].chatwin = num_selected;
122 add_window(m, new_chat(m, num_selected, del_window), i); 120 add_window(m, new_chat(m, num_selected), i);
123 break; 121 break;
124 } 122 }
125 } 123 }
@@ -166,10 +164,7 @@ static void friendlist_onInit(ToxWindow *self, Messenger *m)
166 164
167} 165}
168 166
169ToxWindow new_friendlist(delWindowFn dw, setActiveWindowFn saw, addWindowFn aw, char * ws) { 167ToxWindow new_friendlist(char * ws) {
170 del_window = dw;
171 set_active_window = saw;
172 add_window = aw;
173 WINDOW_STATUS = ws; 168 WINDOW_STATUS = ws;
174 ToxWindow ret; 169 ToxWindow ret;
175 memset(&ret, 0, sizeof(ret)); 170 memset(&ret, 0, sizeof(ret));
diff --git a/testing/toxic/friendlist.h b/testing/toxic/friendlist.h
index e8b93aef..c3d8dac7 100644
--- a/testing/toxic/friendlist.h
+++ b/testing/toxic/friendlist.h
@@ -1,12 +1,10 @@
1#ifndef FRIENDLIST_H_53I41IM 1#ifndef FRIENDLIST_H_53I41IM
2#define FRIENDLIST_H_53I41IM 2#define FRIENDLIST_H_53I41IM
3 3
4
5#include "windows.h" 4#include "windows.h"
6#include "chat.h" 5#include "chat.h"
7typedef void (setActiveWindowFn)(int ch); 6
8typedef int (addWindowFn)(Messenger *m, ToxWindow w, int n); 7ToxWindow new_friendlist(char * ws);
9ToxWindow new_friendlist(delWindowFn dw, setActiveWindowFn saw, addWindowFn aw, char * ws);
10int friendlist_onFriendAdded(Messenger *m, int num); 8int friendlist_onFriendAdded(Messenger *m, int num);
11void disable_chatwin(int f_num); 9void disable_chatwin(int f_num);
12void fix_name(uint8_t *name); 10void fix_name(uint8_t *name);
diff --git a/testing/toxic/windows.c b/testing/toxic/windows.c
index c3952432..d19392ac 100644
--- a/testing/toxic/windows.c
+++ b/testing/toxic/windows.c
@@ -165,7 +165,7 @@ ToxWindow * init_windows()
165 int n_prompt = 0; 165 int n_prompt = 0;
166 int n_friendslist = 1; 166 int n_friendslist = 1;
167 if (add_window(m, new_prompt(on_friendadded), n_prompt) == -1 167 if (add_window(m, new_prompt(on_friendadded), n_prompt) == -1
168 || add_window(m, new_friendlist(del_window, set_active_window, add_window, WINDOW_STATUS), n_friendslist) == -1) { 168 || add_window(m, new_friendlist(WINDOW_STATUS), n_friendslist) == -1) {
169 fprintf(stderr, "add_window() failed.\n"); 169 fprintf(stderr, "add_window() failed.\n");
170 endwin(); 170 endwin();
171 exit(1); 171 exit(1);
diff --git a/testing/toxic/windows.h b/testing/toxic/windows.h
index 613fa3b3..37f3e9da 100644
--- a/testing/toxic/windows.h
+++ b/testing/toxic/windows.h
@@ -46,5 +46,8 @@ void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t l
46void init_window_status(); 46void init_window_status();
47ToxWindow * init_windows(); 47ToxWindow * init_windows();
48void draw_active_window(Messenger * m); 48void draw_active_window(Messenger * m);
49int add_window(Messenger *m, ToxWindow w, int n);
50void del_window(ToxWindow *w, int f_num);
51void set_active_window(int ch);
49#endif 52#endif
50 53