summaryrefslogtreecommitdiff
path: root/testing/toxic/friendlist.c
diff options
context:
space:
mode:
authorChris Hall <followingthepath@gmail.com>2013-08-11 15:24:11 +1200
committerChris Hall <followingthepath@gmail.com>2013-08-12 21:37:38 +1200
commit4293c4b1e66e9547f88c86bd580b9a4c79ca7ace (patch)
tree035448a709db7cab74d9d40fcfec641694f375ec /testing/toxic/friendlist.c
parent139d915482c82f2a4aa87b444008afffef728561 (diff)
Messenger refactor - redid work from pull request 79
Moves static state out of Messenger.c and into a Messenger struct Purely stylistic, no functional changes were made. This commit also changed all the callers of Messenger as they now have to pass an instance of the Messenger struct to messenger functions. Also removed some uses of the 'static' keyword at the beginning of function definitions when the function was already declared static, as these caused gcc to whine.
Diffstat (limited to 'testing/toxic/friendlist.c')
-rw-r--r--testing/toxic/friendlist.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/testing/toxic/friendlist.c b/testing/toxic/friendlist.c
index f2aa1cf4..56061cf9 100644
--- a/testing/toxic/friendlist.c
+++ b/testing/toxic/friendlist.c
@@ -14,7 +14,7 @@
14 14
15extern char WINDOW_STATUS[TOXWINDOWS_MAX_NUM]; 15extern char WINDOW_STATUS[TOXWINDOWS_MAX_NUM];
16extern int add_window(ToxWindow w, int n); 16extern int add_window(ToxWindow w, int n);
17extern ToxWindow new_chat(int friendnum); 17extern ToxWindow new_chat(Messenger *m, int friendnum);
18 18
19extern int active_window; 19extern int active_window;
20 20
@@ -42,7 +42,7 @@ void fix_name(uint8_t *name)
42 *q = 0; 42 *q = 0;
43} 43}
44 44
45void friendlist_onMessage(ToxWindow *self, int num, uint8_t *str, uint16_t len) 45void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str, uint16_t len)
46{ 46{
47 if (num >= num_friends) 47 if (num >= num_friends)
48 return; 48 return;
@@ -54,7 +54,7 @@ void friendlist_onMessage(ToxWindow *self, int num, uint8_t *str, uint16_t len)
54 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) { 54 for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
55 if (WINDOW_STATUS[i] == -1) { 55 if (WINDOW_STATUS[i] == -1) {
56 WINDOW_STATUS[i] = num; 56 WINDOW_STATUS[i] = num;
57 add_window(new_chat(num), i); 57 add_window(new_chat(m, num), i);
58 active_window = i; 58 active_window = i;
59 break; 59 break;
60 } 60 }
@@ -82,20 +82,20 @@ void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t
82 fix_name(friends[num].status); 82 fix_name(friends[num].status);
83} 83}
84 84
85int friendlist_onFriendAdded(int num) 85int friendlist_onFriendAdded(Messenger *m, int num)
86{ 86{
87 if (num_friends == MAX_FRIENDS_NUM) 87 if (num_friends == MAX_FRIENDS_NUM)
88 return -1; 88 return -1;
89 89
90 friends[num_friends].num = num; 90 friends[num_friends].num = num;
91 getname(num, friends[num_friends].name); 91 getname(m, num, friends[num_friends].name);
92 strcpy((char*) friends[num_friends].name, "unknown"); 92 strcpy((char*) friends[num_friends].name, "unknown");
93 strcpy((char*) friends[num_friends].status, "unknown"); 93 strcpy((char*) friends[num_friends].status, "unknown");
94 friends[num_friends++].chatwin = -1; 94 friends[num_friends++].chatwin = -1;
95 return 0; 95 return 0;
96} 96}
97 97
98static void friendlist_onKey(ToxWindow *self, int key) 98static void friendlist_onKey(ToxWindow *self, Messenger *m, int key)
99{ 99{
100 if (key == KEY_UP) { 100 if (key == KEY_UP) {
101 if (--num_selected < 0) 101 if (--num_selected < 0)
@@ -121,7 +121,7 @@ static void friendlist_onKey(ToxWindow *self, int key)
121 if (WINDOW_STATUS[i] == -1) { 121 if (WINDOW_STATUS[i] == -1) {
122 WINDOW_STATUS[i] = num_selected; 122 WINDOW_STATUS[i] = num_selected;
123 friends[num_selected].chatwin = num_selected; 123 friends[num_selected].chatwin = num_selected;
124 add_window(new_chat(num_selected), i); 124 add_window(new_chat(m, num_selected), i);
125 active_window = i; 125 active_window = i;
126 break; 126 break;
127 } 127 }
@@ -164,7 +164,7 @@ void disable_chatwin(int f_num)
164 friends[f_num].chatwin = -1; 164 friends[f_num].chatwin = -1;
165} 165}
166 166
167static void friendlist_onInit(ToxWindow *self) 167static void friendlist_onInit(ToxWindow *self, Messenger *m)
168{ 168{
169 169
170} 170}