mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-16 04:13:02 +01:00
fix bug
This commit is contained in:
parent
7542247c48
commit
5570b7c98a
@ -330,7 +330,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
} else if (!strncmp(line, "/me ", strlen("/me ")))
|
} else if (!strncmp(line, "/me ", strlen("/me ")))
|
||||||
send_action(self, ctx, m, line + strlen("/me "));
|
send_action(self, ctx, m, line + strlen("/me "));
|
||||||
else
|
else
|
||||||
execute(ctx->history, self->prompt, m, line, CHAT_COMMAND_MODE);
|
execute(ctx->history, self->prompt, m, self->num, line, CHAT_COMMAND_MODE);
|
||||||
} else {
|
} else {
|
||||||
/* make sure the string has at least non-space character */
|
/* make sure the string has at least non-space character */
|
||||||
if (!string_is_empty(line)) {
|
if (!string_is_empty(line)) {
|
||||||
@ -469,7 +469,7 @@ static void chat_onInit(ToxWindow *self, Tox *m)
|
|||||||
scrollok(ctx->history, 1);
|
scrollok(ctx->history, 1);
|
||||||
ctx->linewin = subwin(self->window, 0, x, y-4, 0);
|
ctx->linewin = subwin(self->window, 0, x, y-4, 0);
|
||||||
wprintw(ctx->history, "\n\n");
|
wprintw(ctx->history, "\n\n");
|
||||||
execute(ctx->history, self->prompt, m, "/help", CHAT_COMMAND_MODE);
|
execute(ctx->history, self->prompt, m, self->num, "/help", CHAT_COMMAND_MODE);
|
||||||
wmove(self->window, y - CURS_Y_OFFSET, 0);
|
wmove(self->window, y - CURS_Y_OFFSET, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
extern uint8_t pending_grp_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
|
extern uint8_t pending_grp_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
|
||||||
|
|
||||||
void cmd_chat_help(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_chat_help(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
wattron(window, COLOR_PAIR(CYAN) | A_BOLD);
|
wattron(window, COLOR_PAIR(CYAN) | A_BOLD);
|
||||||
wprintw(window, "Chat commands:\n");
|
wprintw(window, "Chat commands:\n");
|
||||||
@ -41,7 +41,7 @@ void cmd_chat_help(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*
|
|||||||
wattroff(window, COLOR_PAIR(CYAN));
|
wattroff(window, COLOR_PAIR(CYAN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_groupinvite(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_groupinvite(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
@ -55,7 +55,7 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tox_invite_friend(m, chatwin->num, groupnum) == -1) {
|
if (tox_invite_friend(m, num, groupnum) == -1) {
|
||||||
wprintw(window, "Failed to invite friend.\n");
|
wprintw(window, "Failed to invite friend.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -63,28 +63,28 @@ void cmd_groupinvite(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char
|
|||||||
wprintw(window, "Invited friend to group chat %d.\n", groupnum);
|
wprintw(window, "Invited friend to group chat %d.\n", groupnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_join_group(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_join_group(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = atoi(argv[1]);
|
int g_num = atoi(argv[1]);
|
||||||
|
|
||||||
if ((num == 0 && strcmp(argv[1], "0")) || num >= MAX_FRIENDS_NUM) {
|
if ((g_num == 0 && strcmp(argv[1], "0")) || g_num >= MAX_FRIENDS_NUM) {
|
||||||
wprintw(window, "No pending group chat invite with that number.\n");
|
wprintw(window, "No pending group chat invite with that number.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *groupkey = pending_grp_requests[num];
|
uint8_t *groupkey = pending_grp_requests[g_num];
|
||||||
|
|
||||||
if (!strlen(groupkey)) {
|
if (!strlen(groupkey)) {
|
||||||
wprintw(window, "No pending group chat invite with that number.\n");
|
wprintw(window, "No pending group chat invite with that number.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int groupnum = tox_join_groupchat(m, num, groupkey);
|
int groupnum = tox_join_groupchat(m, g_num, groupkey);
|
||||||
|
|
||||||
if (groupnum == -1) {
|
if (groupnum == -1) {
|
||||||
wprintw(window, "Group chat instance failed to initialize.\n");
|
wprintw(window, "Group chat instance failed to initialize.\n");
|
||||||
@ -98,7 +98,7 @@ void cmd_join_group(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_savefile(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_savefile(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
@ -112,24 +112,22 @@ void cmd_savefile(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int friendnum = chatwin->num;
|
if (!friends[num].file_receiver.pending[filenum]) {
|
||||||
|
|
||||||
if (!friends[friendnum].file_receiver.pending[filenum]) {
|
|
||||||
wprintw(window, "No pending file transfers with that number.\n");
|
wprintw(window, "No pending file transfers with that number.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *filename = friends[friendnum].file_receiver.filenames[filenum];
|
uint8_t *filename = friends[num].file_receiver.filenames[filenum];
|
||||||
|
|
||||||
if (tox_file_sendcontrol(m, friendnum, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0))
|
if (tox_file_sendcontrol(m, num, 1, filenum, TOX_FILECONTROL_ACCEPT, 0, 0))
|
||||||
wprintw(window, "Accepted file transfer %u. Saving file as: '%s'\n", filenum, filename);
|
wprintw(window, "Accepted file transfer %u. Saving file as: '%s'\n", filenum, filename);
|
||||||
else
|
else
|
||||||
wprintw(window, "File transfer failed.\n");
|
wprintw(window, "File transfer failed.\n");
|
||||||
|
|
||||||
friends[friendnum].file_receiver.pending[filenum] = false;
|
friends[num].file_receiver.pending[filenum] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_sendfile(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_sendfile(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (num_file_senders >= MAX_FILES) {
|
if (num_file_senders >= MAX_FILES) {
|
||||||
wprintw(window,"Please wait for some of your outgoing file transfers to complete.\n");
|
wprintw(window,"Please wait for some of your outgoing file transfers to complete.\n");
|
||||||
@ -167,8 +165,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*a
|
|||||||
uint64_t filesize = ftell(file_to_send);
|
uint64_t filesize = ftell(file_to_send);
|
||||||
fseek(file_to_send, 0, SEEK_SET);
|
fseek(file_to_send, 0, SEEK_SET);
|
||||||
|
|
||||||
int friendnum = chatwin->num;
|
int filenum = tox_new_filesender(m, num, filesize, path, path_len + 1);
|
||||||
int filenum = tox_new_filesender(m, friendnum, filesize, path, path_len + 1);
|
|
||||||
|
|
||||||
if (filenum == -1) {
|
if (filenum == -1) {
|
||||||
wprintw(window, "Error sending file.\n");
|
wprintw(window, "Error sending file.\n");
|
||||||
@ -184,9 +181,9 @@ void cmd_sendfile(WINDOW *window, ToxWindow *chatwin, Tox *m, int argc, char (*a
|
|||||||
file_senders[i].chatwin = window;
|
file_senders[i].chatwin = window;
|
||||||
file_senders[i].file = file_to_send;
|
file_senders[i].file = file_to_send;
|
||||||
file_senders[i].filenum = (uint8_t) filenum;
|
file_senders[i].filenum = (uint8_t) filenum;
|
||||||
file_senders[i].friendnum = friendnum;
|
file_senders[i].friendnum = num;
|
||||||
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
||||||
tox_filedata_size(m, friendnum), file_to_send);
|
tox_filedata_size(m, num), file_to_send);
|
||||||
|
|
||||||
wprintw(window, "Sending file: '%s'\n", path);
|
wprintw(window, "Sending file: '%s'\n", path);
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* Toxic -- Tox Curses Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_chat_help(WINDOW *w, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_chat_help(WINDOW *w, ToxWindow *chatwin, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_groupinvite(WINDOW *w, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_groupinvite(WINDOW *w, ToxWindow *chatwin, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_join_group(WINDOW *w, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_join_group(WINDOW *w, ToxWindow *chatwin, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_savefile(WINDOW *w, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_savefile(WINDOW *w, ToxWindow *chatwin, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_sendfile(WINDOW *w, ToxWindow *chatwin, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_sendfile(WINDOW *w, ToxWindow *chatwin, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
struct cmd_func {
|
struct cmd_func {
|
||||||
const char *name;
|
const char *name;
|
||||||
void (*func)(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void (*func)(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GLOBAL_NUM_COMMANDS 12
|
#define GLOBAL_NUM_COMMANDS 12
|
||||||
@ -78,14 +78,14 @@ static int parse_command(WINDOW *w, char *cmd, char (*args)[MAX_STR_SIZE])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Matches command to respective function. Returns 0 on match, 1 on no match */
|
/* Matches command to respective function. Returns 0 on match, 1 on no match */
|
||||||
static int do_command(WINDOW *w, ToxWindow *prompt, Tox *m, int num_args, int num_cmds,
|
static int do_command(WINDOW *w, ToxWindow *prompt, Tox *m, int num, int num_args, int num_cmds,
|
||||||
struct cmd_func *commands, char (*args)[MAX_STR_SIZE])
|
struct cmd_func *commands, char (*args)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_cmds; ++i) {
|
for (i = 0; i < num_cmds; ++i) {
|
||||||
if (strcmp(args[0], commands[i].name) == 0) {
|
if (strcmp(args[0], commands[i].name) == 0) {
|
||||||
(commands[i].func)(w, prompt, m, num_args-1, args);
|
(commands[i].func)(w, prompt, m, num, num_args-1, args);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ static int do_command(WINDOW *w, ToxWindow *prompt, Tox *m, int num_args, int nu
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute(WINDOW *w, ToxWindow *prompt, Tox *m, char *cmd, int mode)
|
void execute(WINDOW *w, ToxWindow *prompt, Tox *m, int num, char *cmd, int mode)
|
||||||
{
|
{
|
||||||
if (string_is_empty(cmd))
|
if (string_is_empty(cmd))
|
||||||
return;
|
return;
|
||||||
@ -108,7 +108,7 @@ void execute(WINDOW *w, ToxWindow *prompt, Tox *m, char *cmd, int mode)
|
|||||||
try specified mode's commands first, then upon failure try global commands. */
|
try specified mode's commands first, then upon failure try global commands. */
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case CHAT_COMMAND_MODE:
|
case CHAT_COMMAND_MODE:
|
||||||
if (do_command(w, prompt, m, num_args, CHAT_NUM_COMMANDS, chat_commands, args) == 0)
|
if (do_command(w, prompt, m, num, num_args, CHAT_NUM_COMMANDS, chat_commands, args) == 0)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ void execute(WINDOW *w, ToxWindow *prompt, Tox *m, char *cmd, int mode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_command(w, prompt, m, num_args, GLOBAL_NUM_COMMANDS, global_commands, args) == 0)
|
if (do_command(w, prompt, m, num, num_args, GLOBAL_NUM_COMMANDS, global_commands, args) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wprintw(w, "Invalid command.\n");
|
wprintw(w, "Invalid command.\n");
|
||||||
|
@ -10,4 +10,4 @@ enum {
|
|||||||
GROUPCHAT_COMMAND_MODE,
|
GROUPCHAT_COMMAND_MODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
void execute(WINDOW *w, ToxWindow *prompt, Tox *m, char *cmd, int mode);
|
void execute(WINDOW *w, ToxWindow *prompt, Tox *m, int num, char *cmd, int mode);
|
||||||
|
@ -18,7 +18,7 @@ extern uint8_t pending_frnd_requests[MAX_FRIENDS_NUM][TOX_CLIENT_ID_SIZE];
|
|||||||
extern uint8_t num_frnd_requests;
|
extern uint8_t num_frnd_requests;
|
||||||
|
|
||||||
/* command functions */
|
/* command functions */
|
||||||
void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
@ -26,19 +26,19 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = atoi(argv[1]);
|
int req = atoi(argv[1]);
|
||||||
|
|
||||||
if ((num == 0 && strcmp(argv[1], "0"))|| num >= MAX_FRIENDS_NUM) {
|
if ((req == 0 && strcmp(argv[1], "0"))|| req >= MAX_FRIENDS_NUM) {
|
||||||
wprintw(window, "No pending friend request with that number.\n");
|
wprintw(window, "No pending friend request with that number.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen(pending_frnd_requests[num])) {
|
if (!strlen(pending_frnd_requests[req])) {
|
||||||
wprintw(window, "No pending friend request with that number.\n");
|
wprintw(window, "No pending friend request with that number.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int friendnum = tox_addfriend_norequest(m, pending_frnd_requests[num]);
|
int friendnum = tox_addfriend_norequest(m, pending_frnd_requests[req]);
|
||||||
|
|
||||||
if (friendnum == -1)
|
if (friendnum == -1)
|
||||||
wprintw(window, "Failed to add friend.\n");
|
wprintw(window, "Failed to add friend.\n");
|
||||||
@ -47,7 +47,7 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
|
|||||||
on_friendadded(m, friendnum);
|
on_friendadded(m, friendnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&pending_frnd_requests[num], 0, TOX_CLIENT_ID_SIZE);
|
memset(&pending_frnd_requests[req], 0, TOX_CLIENT_ID_SIZE);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
|
|||||||
num_frnd_requests = i;
|
num_frnd_requests = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
wprintw(window, "Invalid syntax.\n");
|
wprintw(window, "Invalid syntax.\n");
|
||||||
@ -109,9 +109,9 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[M
|
|||||||
id[i] = toupper(id[i]);
|
id[i] = toupper(id[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = tox_addfriend(m, id_bin, msg, strlen(msg) + 1);
|
int f_num = tox_addfriend(m, id_bin, msg, strlen(msg) + 1);
|
||||||
|
|
||||||
switch (num) {
|
switch (f_num) {
|
||||||
case TOX_FAERR_TOOLONG:
|
case TOX_FAERR_TOOLONG:
|
||||||
wprintw(window, "Message is too long.\n");
|
wprintw(window, "Message is too long.\n");
|
||||||
break;
|
break;
|
||||||
@ -135,18 +135,18 @@ void cmd_add(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[M
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wprintw(window, "Friend request sent.\n");
|
wprintw(window, "Friend request sent.\n");
|
||||||
on_friendadded(m, num);
|
on_friendadded(m, f_num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_clear(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_clear(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
wclear(window);
|
wclear(window);
|
||||||
wprintw(window, "\n\n");
|
wprintw(window, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_connect(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
@ -170,7 +170,7 @@ void cmd_connect(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*arg
|
|||||||
free(binary_string);
|
free(binary_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_groupchat(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_groupchat(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
int ngc = get_num_groupchats();
|
int ngc = get_num_groupchats();
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*a
|
|||||||
wprintw(window, "Group chat created as %d.\n", groupnum);
|
wprintw(window, "Group chat created as %d.\n", groupnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
||||||
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
|
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
|
||||||
@ -212,7 +212,7 @@ void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[
|
|||||||
wprintw(window, "%s\n", id);
|
wprintw(window, "%s\n", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_nick(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_nick(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
/* check arguments */
|
/* check arguments */
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
@ -240,7 +240,7 @@ void cmd_nick(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[
|
|||||||
store_data(m, DATA_FILE);
|
store_data(m, DATA_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_note(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_note(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
wprintw(window, "Wrong number of arguments.\n");
|
wprintw(window, "Wrong number of arguments.\n");
|
||||||
@ -260,12 +260,12 @@ void cmd_note(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[
|
|||||||
prompt_update_statusmessage(prompt, msg, len);
|
prompt_update_statusmessage(prompt, msg, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_quit(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_quit(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
exit_toxic(m);
|
exit_toxic(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_status(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_status(WINDOW *window, ToxWindow *prompt, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
{
|
{
|
||||||
uint8_t *msg = NULL;
|
uint8_t *msg = NULL;
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
* Toxic -- Tox Curses Client
|
* Toxic -- Tox Curses Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_accept(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_accept(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_add(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_add(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_clear(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_clear(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_connect(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_connect(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_groupchat(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_groupchat(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_myid(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_myid(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_nick(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_nick(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_note(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_note(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_quit(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_quit(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_status(WINDOW *, ToxWindow *, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_status(WINDOW *, ToxWindow *, Tox *m, int num, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
|
@ -170,7 +170,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
} else if (strncmp(line, "/help", strlen("/help")) == 0)
|
} else if (strncmp(line, "/help", strlen("/help")) == 0)
|
||||||
print_groupchat_help(ctx);
|
print_groupchat_help(ctx);
|
||||||
else
|
else
|
||||||
execute(ctx->history, self->prompt, m, line, GROUPCHAT_COMMAND_MODE);
|
execute(ctx->history, self->prompt, m, self->num, line, GROUPCHAT_COMMAND_MODE);
|
||||||
} else {
|
} else {
|
||||||
/* make sure the string has at least non-space character */
|
/* make sure the string has at least non-space character */
|
||||||
if (!string_is_empty(line)) {
|
if (!string_is_empty(line)) {
|
||||||
|
@ -133,7 +133,7 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
|
|||||||
if (!strncmp(prompt_buf, "/help", strlen("/help")))
|
if (!strncmp(prompt_buf, "/help", strlen("/help")))
|
||||||
print_prompt_help(self);
|
print_prompt_help(self);
|
||||||
else
|
else
|
||||||
execute(self->window, self, m, prompt_buf, GLOBAL_COMMAND_MODE);
|
execute(self->window, self, m, self->num, prompt_buf, GLOBAL_COMMAND_MODE);
|
||||||
|
|
||||||
prompt_buf_pos = 0;
|
prompt_buf_pos = 0;
|
||||||
prompt_buf[0] = '\0';
|
prompt_buf[0] = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user