summaryrefslogtreecommitdiff
path: root/testing/toxic/friendlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/friendlist.c')
-rw-r--r--testing/toxic/friendlist.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index c85fd3ae..0a58bc54 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -13,7 +13,6 @@
13#include "windows.h" 13#include "windows.h"
14#include "friendlist.h" 14#include "friendlist.h"
15 15
16static char *WINDOW_STATUS;
17 16
18typedef struct { 17typedef struct {
19 uint8_t name[MAX_NAME_LENGTH]; 18 uint8_t name[MAX_NAME_LENGTH];
@@ -48,17 +47,7 @@ void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str,
48 return; 47 return;
49 48
50 if (friends[num].chatwin == -1) { 49 if (friends[num].chatwin == -1) {
51 friends[num].chatwin = num; 50 friends[num].chatwin = add_window(m, new_chat(m, num));
52 int i;
53
54 /* Find first open slot to hold chat window */
55 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
56 if (WINDOW_STATUS[i] == -1) {
57 WINDOW_STATUS[i] = num;
58 add_window(m, new_chat(m, num), i);
59 break;
60 }
61 }
62 } 51 }
63} 52}
64 53
@@ -106,25 +95,9 @@ static void friendlist_onKey(ToxWindow *self, Messenger *m, int key)
106 } else if (key == '\n') { 95 } else if (key == '\n') {
107 /* Jump to chat window if already open */ 96 /* Jump to chat window if already open */
108 if (friends[num_selected].chatwin != -1) { 97 if (friends[num_selected].chatwin != -1) {
109 int i; 98 set_active_window(friends[num_selected].chatwin);
110
111 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
112 if (WINDOW_STATUS[i] == num_selected) {
113 set_active_window(i);
114 break;
115 }
116 }
117 } else { 99 } else {
118 int i; 100 friends[num_selected].chatwin = add_window(m, new_chat(m, num_selected));
119
120 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
121 if (WINDOW_STATUS[i] == -1) {
122 WINDOW_STATUS[i] = num_selected;
123 friends[num_selected].chatwin = num_selected;
124 add_window(m, new_chat(m, num_selected), i);
125 break;
126 }
127 }
128 } 101 }
129 } 102 }
130} 103}
@@ -172,9 +145,8 @@ static void friendlist_onInit(ToxWindow *self, Messenger *m)
172 145
173} 146}
174 147
175ToxWindow new_friendlist(char *ws) 148ToxWindow new_friendlist()
176{ 149{
177 WINDOW_STATUS = ws;
178 ToxWindow ret; 150 ToxWindow ret;
179 memset(&ret, 0, sizeof(ret)); 151 memset(&ret, 0, sizeof(ret));
180 152