2014-06-12 00:06:55 +02:00
|
|
|
/* toxic.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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#ifndef TOXIC_H
|
|
|
|
#define TOXIC_H
|
2014-06-12 00:06:55 +02:00
|
|
|
|
|
|
|
#ifndef TOXICVER
|
2014-10-08 08:45:08 +02:00
|
|
|
#define TOXICVER "NOVERS" /* Use the -D flag to set this */
|
2014-06-12 00:06:55 +02:00
|
|
|
#endif
|
|
|
|
|
2014-07-04 09:24:29 +02:00
|
|
|
#ifndef SIGWINCH
|
|
|
|
#define SIGWINCH 28
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SIGINT
|
|
|
|
#define SIGINT 2
|
|
|
|
#endif
|
|
|
|
|
2014-06-12 00:06:55 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <curses.h>
|
|
|
|
|
|
|
|
#include <tox/tox.h>
|
|
|
|
|
2015-07-09 03:08:55 +02:00
|
|
|
#define UNKNOWN_NAME "Anonymous"
|
|
|
|
#define DEFAULT_TOX_NAME "Tox User" /* should always be the same as toxcore's default name */
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-10-03 23:53:50 +02:00
|
|
|
#define MAX_STR_SIZE TOX_MAX_MESSAGE_LENGTH /* must be >= TOX_MAX_MESSAGE_LENGTH */
|
2014-06-12 00:06:55 +02:00
|
|
|
#define MAX_CMDNAME_SIZE 64
|
|
|
|
#define TOXIC_MAX_NAME_LENGTH 32 /* Must be <= TOX_MAX_NAME_LENGTH */
|
2014-09-23 00:38:46 +02:00
|
|
|
#define KEY_IDENT_DIGITS 3 /* number of hex digits to display for the pub-key based identifier */
|
2015-02-20 00:20:38 +01:00
|
|
|
#define TIME_STR_SIZE 32
|
2014-06-12 00:06:55 +02:00
|
|
|
|
|
|
|
/* ASCII key codes */
|
2014-07-29 03:40:06 +02:00
|
|
|
#define T_KEY_ESC 0x1B /* ESC key */
|
2014-06-12 00:06:55 +02:00
|
|
|
#define T_KEY_KILL 0x0B /* ctrl-k */
|
|
|
|
#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 */
|
2014-06-13 09:46:01 +02:00
|
|
|
#define T_KEY_C_RB 0x1D /* ctrl-] */
|
|
|
|
#define T_KEY_C_LB 0x1B /* ctrl-[ */
|
2014-06-20 20:27:33 +02:00
|
|
|
#define T_KEY_C_V 0x16 /* ctrl-v */
|
|
|
|
#define T_KEY_C_F 0x06 /* ctrl-f */
|
2014-06-19 02:07:34 +02:00
|
|
|
#define T_KEY_C_H 0x08 /* ctrl-h */
|
2014-07-14 20:32:38 +02:00
|
|
|
#define T_KEY_C_Y 0x19 /* ctrl-y */
|
2014-10-01 22:24:36 +02:00
|
|
|
#define T_KEY_C_L 0x0C /* ctrl-l */
|
2014-10-06 05:12:58 +02:00
|
|
|
#define T_KEY_C_W 0x17 /* ctrl-w */
|
2014-10-08 08:45:08 +02:00
|
|
|
#define T_KEY_C_B 0x02 /* ctrl-b */
|
2014-07-29 03:40:06 +02:00
|
|
|
#define T_KEY_TAB 0x09 /* TAB key */
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-07-27 01:16:07 +02:00
|
|
|
#define ONLINE_CHAR "*"
|
2014-07-28 02:16:54 +02:00
|
|
|
#define OFFLINE_CHAR "o"
|
2014-07-27 01:16:07 +02:00
|
|
|
|
2014-06-18 21:54:05 +02:00
|
|
|
typedef enum _FATAL_ERRS {
|
2014-07-29 01:36:30 +02:00
|
|
|
FATALERR_MEMORY = -1, /* heap memory allocation failed */
|
2014-09-24 04:51:56 +02:00
|
|
|
FATALERR_FILEOP = -2, /* critical file operation failed */
|
|
|
|
FATALERR_THREAD_CREATE = -3, /* thread creation failed for critical thread */
|
|
|
|
FATALERR_MUTEX_INIT = -4, /* mutex init for critical thread failed */
|
2014-07-10 05:40:46 +02:00
|
|
|
FATALERR_THREAD_ATTR = -5, /* thread attr object init failed */
|
2015-03-26 03:56:45 +01:00
|
|
|
FATALERR_LOCALE_NOT_SET = -6, /* system locale not set */
|
2014-07-10 05:40:46 +02:00
|
|
|
FATALERR_STORE_DATA = -7, /* store_data failed in critical section */
|
2015-03-26 03:56:45 +01:00
|
|
|
FATALERR_INFLOOP = -8, /* infinite loop detected */
|
|
|
|
FATALERR_WININIT = -9, /* window init failed */
|
|
|
|
FATALERR_PROXY = -10, /* Tox network failed to init using a proxy */
|
|
|
|
FATALERR_ENCRYPT = -11, /* Data file encryption failure */
|
2015-04-01 03:56:11 +02:00
|
|
|
FATALERR_TOX_INIT = -12, /* Tox instance failed to initialize */
|
2014-06-18 21:54:05 +02:00
|
|
|
} FATAL_ERRS;
|
|
|
|
|
2014-06-12 00:06:55 +02:00
|
|
|
/* Fixes text color problem on some terminals.
|
|
|
|
Uncomment if necessary */
|
|
|
|
/* #define URXVT_FIX */
|
|
|
|
|
2015-02-26 22:51:20 +01:00
|
|
|
void lock_status ();
|
|
|
|
void unlock_status ();
|
|
|
|
|
2014-06-18 21:54:05 +02:00
|
|
|
void exit_toxic_success(Tox *m);
|
2014-06-18 21:54:50 +02:00
|
|
|
void exit_toxic_err(const char *errmsg, int errcode);
|
2014-06-18 21:54:05 +02:00
|
|
|
|
2014-09-14 23:46:28 +02:00
|
|
|
int store_data(Tox *m, const char *path);
|
2014-06-22 03:41:38 +02:00
|
|
|
|
2015-03-26 03:56:45 +01:00
|
|
|
/* callbacks */
|
|
|
|
void on_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata);
|
2015-03-28 07:56:54 +01:00
|
|
|
void on_connectionchange(Tox *m, uint32_t friendnumber, TOX_CONNECTION status, void *userdata);
|
2015-03-26 03:56:45 +01:00
|
|
|
void on_message(Tox *m, uint32_t friendnumber, TOX_MESSAGE_TYPE type, const uint8_t *string, size_t length, void *userdata);
|
|
|
|
void on_action(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata);
|
|
|
|
void on_nickchange(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata);
|
|
|
|
void on_statuschange(Tox *m, uint32_t friendnumber, TOX_USER_STATUS status, void *userdata);
|
|
|
|
void on_statusmessagechange(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata);
|
|
|
|
void on_friendadded(Tox *m, uint32_t friendnumber, bool sort);
|
|
|
|
void on_file_chunk_request(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length, void *userdata);
|
2015-03-28 07:56:54 +01:00
|
|
|
void on_file_recv_chunk(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
|
|
|
size_t length, void *userdata);
|
2015-03-26 03:56:45 +01:00
|
|
|
void on_file_control (Tox *m, uint32_t friendnumber, uint32_t filenumber, TOX_FILE_CONTROL control, void *userdata);
|
|
|
|
void on_file_recv(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint32_t kind, uint64_t file_size,
|
|
|
|
const uint8_t *filename, size_t filename_length, void *userdata);
|
2015-03-28 07:56:54 +01:00
|
|
|
void on_typing_change(Tox *m, uint32_t friendnumber, bool is_typing, void *userdata);
|
2015-03-26 03:56:45 +01:00
|
|
|
void on_read_receipt(Tox *m, uint32_t friendnumber, uint32_t receipt, void *userdata);
|
2015-07-14 04:12:13 +02:00
|
|
|
void on_group_invite(Tox *m, int32_t friendnumber, const uint8_t *invite_data, size_t length, void *userdata);
|
|
|
|
void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type,
|
|
|
|
const uint8_t *message, size_t length, void *userdata);
|
|
|
|
void on_group_private_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *message, size_t length, void *userdata);
|
|
|
|
void on_group_namelistchange(Tox *m, uint32_t groupnumber, void *userdata);
|
|
|
|
void on_group_peer_join(Tox *m, uint32_t groupnumber, uint32_t peernumber, void *userdata);
|
|
|
|
void on_group_peer_exit(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *partmsg, size_t length, void *userdata);
|
|
|
|
void on_group_topic_change(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *topic, size_t length, void *userdata);
|
2015-07-14 08:07:52 +02:00
|
|
|
void on_group_peer_limit(Tox *m, uint32_t groupnumber, uint32_t peer_limit, void *userdata);
|
|
|
|
void on_group_privacy_state(Tox *m, uint32_t groupnumber, TOX_GROUP_PRIVACY_STATE privacy_state, void *userdata);
|
|
|
|
void on_group_password(Tox *m, uint32_t groupnumber, const uint8_t *password, size_t length, void *userdata);
|
2015-07-14 04:12:13 +02:00
|
|
|
void on_group_nick_change(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *newname, size_t length, void *userdata);
|
|
|
|
void on_group_self_join(Tox *m, uint32_t groupnumber, void *userdata);
|
|
|
|
void on_group_rejected(Tox *m, uint32_t groupnumber, TOX_GROUP_JOIN_FAIL type, void *userdata);
|
|
|
|
void on_group_moderation(Tox *m, uint32_t groupnumber, uint32_t source_peernum, uint32_t target_peernum,
|
2015-05-29 08:00:18 +02:00
|
|
|
TOX_GROUP_MOD_EVENT type, void *userdata);
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#endif /* #define TOXIC_H */
|