1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-04 20:36:45 +02:00

Toxic now supports audio calls

This commit is contained in:
mannol
2014-03-07 03:27:48 +01:00
33 changed files with 1227 additions and 345 deletions

View File

@ -1,5 +1,23 @@
/*
* Toxic -- Tox Curses Client
/* toxic_windows.h
*
*
* Copyright (C) 2014 Toxic All Rights Reserved.
*
* This file is part of Toxic.
*
* Toxic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Toxic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _windows_h
@ -40,6 +58,8 @@
#define T_KEY_DISCARD 0x15 /* ctrl-u */
#define T_KEY_NEXT 0x10 /* ctrl-p */
#define T_KEY_PREV 0x0F /* ctrl-o */
#define T_KEY_C_E 0x05 /* ctrl-e */
#define T_KEY_C_A 0x01 /* ctrl-a */
/* Curses foreground colours (background is black) */
enum {
@ -88,6 +108,7 @@ struct ToxWindow {
void(*onFileSendRequest)(ToxWindow *, Tox *, int, uint8_t, uint64_t, uint8_t *, uint16_t);
void(*onFileControl)(ToxWindow *, Tox *, int, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t);
void(*onFileData)(ToxWindow *, Tox *, int, uint8_t, uint8_t *, uint16_t);
void(*onTypingChange)(ToxWindow *, Tox *, int, int);
#ifdef _SUPPORT_AUDIO
@ -109,6 +130,11 @@ struct ToxWindow {
bool active;
int x;
/* window type identifiers */
bool is_chat;
bool is_groupchat;
bool is_prompt;
bool alert0;
bool alert1;
bool alert2;
@ -131,6 +157,15 @@ struct StatusBar {
bool is_online;
};
#define LOG_FLUSH_LIMIT 2 /* limits calls to fflush(logfile) to a max of one per LOG_FLUSH_LIMIT seconds */
struct chatlog {
FILE *file;
uint64_t lastwrite;
int pos;
bool log_on; /* specific to current chat window */
};
#define MAX_LINE_HIST 128
/* chat and groupchat window/buffer holder */
@ -143,6 +178,10 @@ struct ChatContext {
int hst_pos;
int hst_tot;
bool self_is_typing;
struct chatlog *log;
WINDOW *history;
WINDOW *linewin;
WINDOW *sidebar;
@ -153,6 +192,7 @@ struct PromptBuf {
wchar_t line[MAX_STR_SIZE];
size_t pos;
size_t len;
bool at_bottom; /* true if line end is at bottom of window */
int orig_y; /* y axis point of line origin */
bool scroll; /* used for prompt window hack to determine when to scroll down */
@ -161,6 +201,7 @@ struct PromptBuf {
int hst_pos;
int hst_tot;
struct chatlog *log;
WINDOW *linewin;
};
@ -184,6 +225,7 @@ typedef struct {
struct FileReceiver {
uint8_t filenames[MAX_FILES][MAX_STR_SIZE];
FILE *files[MAX_FILES];
bool pending[MAX_FILES];
};
@ -204,6 +246,7 @@ void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t ch
void on_file_sendrequest(Tox *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *pathname, uint16_t pathname_length, void *userdata);
void on_file_control(Tox *m, int friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata);
void on_file_data(Tox *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata);
void on_typing_change(Tox *m, int friendnumber, int is_typing, void *userdata);
ToxWindow *init_windows(Tox *m);
void draw_active_window(Tox *m);
@ -211,4 +254,7 @@ int add_window(Tox *m, ToxWindow w);
void del_window(ToxWindow *w);
void set_active_window(int ch);
int num_active_windows(void);
/* cleans up all chat and groupchat windows (should only be called on shutdown) */
void kill_all_windows(void);
#endif