mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:23:02 +01:00
remove temporary callbacks from refactoring
This commit is contained in:
parent
722d272128
commit
4a3292a32b
5
chat.c
5
chat.c
@ -26,8 +26,6 @@ typedef struct {
|
|||||||
WINDOW* linewin;
|
WINDOW* linewin;
|
||||||
} ChatContext;
|
} ChatContext;
|
||||||
|
|
||||||
static delWindowFn *del_window;
|
|
||||||
|
|
||||||
void print_help(ChatContext *self);
|
void print_help(ChatContext *self);
|
||||||
void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd);
|
void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd);
|
||||||
|
|
||||||
@ -370,9 +368,8 @@ void print_help(ChatContext *self)
|
|||||||
wattroff(self->history, COLOR_PAIR(2));
|
wattroff(self->history, COLOR_PAIR(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxWindow new_chat(Messenger *m, int friendnum, delWindowFn *f)
|
ToxWindow new_chat(Messenger *m, int friendnum)
|
||||||
{
|
{
|
||||||
del_window = f;
|
|
||||||
ToxWindow ret;
|
ToxWindow ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
|
|
||||||
|
3
chat.h
3
chat.h
@ -1,7 +1,6 @@
|
|||||||
#ifndef CHAT_H_6489PZ13
|
#ifndef CHAT_H_6489PZ13
|
||||||
#define CHAT_H_6489PZ13
|
#define CHAT_H_6489PZ13
|
||||||
|
|
||||||
typedef void (delWindowFn)(ToxWindow *w, int f_num);
|
ToxWindow new_chat(Messenger *m, int friendnum);
|
||||||
ToxWindow new_chat(Messenger *m, int friendnum, delWindowFn f);
|
|
||||||
|
|
||||||
#endif /* end of include guard: CHAT_H_6489PZ13 */
|
#endif /* end of include guard: CHAT_H_6489PZ13 */
|
||||||
|
13
friendlist.c
13
friendlist.c
@ -10,11 +10,9 @@
|
|||||||
#include "../../core/Messenger.h"
|
#include "../../core/Messenger.h"
|
||||||
#include "../../core/network.h"
|
#include "../../core/network.h"
|
||||||
|
|
||||||
|
#include "windows.h"
|
||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
|
|
||||||
static delWindowFn *del_window;
|
|
||||||
static setActiveWindowFn *set_active_window;
|
|
||||||
static addWindowFn *add_window;
|
|
||||||
static char * WINDOW_STATUS;
|
static char * WINDOW_STATUS;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -53,7 +51,7 @@ void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str,
|
|||||||
for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
|
for (i = N_DEFAULT_WINS; i < MAX_WINDOW_SLOTS; ++i) {
|
||||||
if (WINDOW_STATUS[i] == -1) {
|
if (WINDOW_STATUS[i] == -1) {
|
||||||
WINDOW_STATUS[i] = num;
|
WINDOW_STATUS[i] = num;
|
||||||
add_window(m, new_chat(m, num, del_window), i);
|
add_window(m, new_chat(m, num), i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +117,7 @@ static void friendlist_onKey(ToxWindow *self, Messenger *m, int key)
|
|||||||
if (WINDOW_STATUS[i] == -1) {
|
if (WINDOW_STATUS[i] == -1) {
|
||||||
WINDOW_STATUS[i] = num_selected;
|
WINDOW_STATUS[i] = num_selected;
|
||||||
friends[num_selected].chatwin = num_selected;
|
friends[num_selected].chatwin = num_selected;
|
||||||
add_window(m, new_chat(m, num_selected, del_window), i);
|
add_window(m, new_chat(m, num_selected), i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,10 +164,7 @@ static void friendlist_onInit(ToxWindow *self, Messenger *m)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxWindow new_friendlist(delWindowFn dw, setActiveWindowFn saw, addWindowFn aw, char * ws) {
|
ToxWindow new_friendlist(char * ws) {
|
||||||
del_window = dw;
|
|
||||||
set_active_window = saw;
|
|
||||||
add_window = aw;
|
|
||||||
WINDOW_STATUS = ws;
|
WINDOW_STATUS = ws;
|
||||||
ToxWindow ret;
|
ToxWindow ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#ifndef FRIENDLIST_H_53I41IM
|
#ifndef FRIENDLIST_H_53I41IM
|
||||||
#define FRIENDLIST_H_53I41IM
|
#define FRIENDLIST_H_53I41IM
|
||||||
|
|
||||||
|
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
typedef void (setActiveWindowFn)(int ch);
|
|
||||||
typedef int (addWindowFn)(Messenger *m, ToxWindow w, int n);
|
ToxWindow new_friendlist(char * ws);
|
||||||
ToxWindow new_friendlist(delWindowFn dw, setActiveWindowFn saw, addWindowFn aw, char * ws);
|
|
||||||
int friendlist_onFriendAdded(Messenger *m, int num);
|
int friendlist_onFriendAdded(Messenger *m, int num);
|
||||||
void disable_chatwin(int f_num);
|
void disable_chatwin(int f_num);
|
||||||
void fix_name(uint8_t *name);
|
void fix_name(uint8_t *name);
|
||||||
|
@ -165,7 +165,7 @@ ToxWindow * init_windows()
|
|||||||
int n_prompt = 0;
|
int n_prompt = 0;
|
||||||
int n_friendslist = 1;
|
int n_friendslist = 1;
|
||||||
if (add_window(m, new_prompt(on_friendadded), n_prompt) == -1
|
if (add_window(m, new_prompt(on_friendadded), n_prompt) == -1
|
||||||
|| add_window(m, new_friendlist(del_window, set_active_window, add_window, WINDOW_STATUS), n_friendslist) == -1) {
|
|| add_window(m, new_friendlist(WINDOW_STATUS), n_friendslist) == -1) {
|
||||||
fprintf(stderr, "add_window() failed.\n");
|
fprintf(stderr, "add_window() failed.\n");
|
||||||
endwin();
|
endwin();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -46,5 +46,8 @@ void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t l
|
|||||||
void init_window_status();
|
void init_window_status();
|
||||||
ToxWindow * init_windows();
|
ToxWindow * init_windows();
|
||||||
void draw_active_window(Messenger * m);
|
void draw_active_window(Messenger * m);
|
||||||
|
int add_window(Messenger *m, ToxWindow w, int n);
|
||||||
|
void del_window(ToxWindow *w, int f_num);
|
||||||
|
void set_active_window(int ch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user