2013-08-01 02:20:16 +08:00
|
|
|
/*
|
|
|
|
* Toxic -- Tox Curses Client
|
|
|
|
*/
|
2013-08-11 08:58:15 +08:00
|
|
|
#ifndef _windows_h
|
|
|
|
#define _windows_h
|
2013-08-01 02:20:16 +08:00
|
|
|
|
2013-08-11 08:58:15 +08:00
|
|
|
#include <curses.h>
|
|
|
|
#include <stdint.h>
|
2013-08-01 02:20:16 +08:00
|
|
|
#include <stdbool.h>
|
2013-08-11 08:58:15 +08:00
|
|
|
#include "../../core/Messenger.h"
|
2013-08-05 13:57:29 +08:00
|
|
|
#define TOXWINDOWS_MAX_NUM 32
|
|
|
|
#define MAX_FRIENDS_NUM 100
|
2013-08-08 16:51:58 +08:00
|
|
|
#define MAX_STR_SIZE 256
|
|
|
|
#define KEY_SIZE_BYTES 32
|
|
|
|
|
2013-08-05 13:57:29 +08:00
|
|
|
/* number of permanent default windows */
|
2013-08-11 10:49:41 +08:00
|
|
|
#define N_DEFAULT_WINS 3
|
2013-08-05 13:57:29 +08:00
|
|
|
|
|
|
|
/* maximum window slots for WINDOW_STATUS array */
|
|
|
|
#define MAX_WINDOW_SLOTS N_DEFAULT_WINS+MAX_FRIENDS_NUM
|
2013-08-01 02:20:16 +08:00
|
|
|
|
2013-08-14 20:56:29 +08:00
|
|
|
#ifndef TOXICVER
|
|
|
|
#define TOXICVER "NOVER" //Use the -D flag to set this
|
|
|
|
#endif
|
|
|
|
|
2013-07-30 07:32:39 +08:00
|
|
|
typedef struct ToxWindow_ ToxWindow;
|
|
|
|
|
|
|
|
struct ToxWindow_ {
|
2013-08-17 01:11:09 +08:00
|
|
|
void(*onKey)(ToxWindow *, Messenger *, int);
|
|
|
|
void(*onDraw)(ToxWindow *);
|
|
|
|
void(*onInit)(ToxWindow *, Messenger *);
|
|
|
|
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
|
|
|
void(*onMessage)(ToxWindow *, Messenger *, int, uint8_t *, uint16_t);
|
|
|
|
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
|
|
|
void(*onStatusChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
|
|
|
void(*onAction)(ToxWindow *, Messenger *, int, uint8_t *, uint16_t);
|
|
|
|
char title[256];
|
|
|
|
|
|
|
|
void *x;
|
|
|
|
bool blink;
|
|
|
|
|
|
|
|
WINDOW *window;
|
2013-07-30 07:32:39 +08:00
|
|
|
};
|
2013-08-11 08:58:15 +08:00
|
|
|
|
2013-08-17 01:11:09 +08:00
|
|
|
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata);
|
|
|
|
void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
|
|
|
void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
|
|
|
void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
|
|
|
void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
2013-08-15 18:11:48 +08:00
|
|
|
void on_friendadded(Messenger *m, int friendnumber);
|
2013-08-13 08:21:03 +08:00
|
|
|
void init_window_status();
|
2013-08-17 01:11:09 +08:00
|
|
|
ToxWindow *init_windows();
|
|
|
|
void draw_active_window(Messenger *m);
|
2013-08-13 08:32:09 +08:00
|
|
|
int add_window(Messenger *m, ToxWindow w, int n);
|
|
|
|
void del_window(ToxWindow *w, int f_num);
|
|
|
|
void set_active_window(int ch);
|
2013-08-11 08:58:15 +08:00
|
|
|
#endif
|
|
|
|
|