2014-02-25 08:28:24 +01:00
|
|
|
/* chat_commands.c
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
2013-11-10 03:43:56 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-08-04 07:56:43 +02:00
|
|
|
#include "chat.h"
|
2020-04-18 02:00:00 +02:00
|
|
|
#include "conference.h"
|
|
|
|
#include "execute.h"
|
2015-03-28 07:56:54 +01:00
|
|
|
#include "file_transfers.h"
|
2020-04-18 02:00:00 +02:00
|
|
|
#include "friendlist.h"
|
|
|
|
#include "line_info.h"
|
|
|
|
#include "misc_tools.h"
|
|
|
|
#include "toxic.h"
|
|
|
|
#include "windows.h"
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2013-11-19 21:32:35 +01:00
|
|
|
extern ToxWindow *prompt;
|
2014-09-28 23:49:48 +02:00
|
|
|
extern FriendsList Friends;
|
2013-11-30 00:52:21 +01:00
|
|
|
|
2014-08-04 07:56:43 +02:00
|
|
|
void cmd_cancelfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
|
|
|
{
|
2020-03-15 19:57:00 +01:00
|
|
|
UNUSED_VAR(window);
|
|
|
|
|
2014-08-04 07:56:43 +02:00
|
|
|
if (argc < 2) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Requires type in|out and the file ID.");
|
2014-08-04 07:56:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
char msg[MAX_STR_SIZE];
|
2014-08-04 07:56:43 +02:00
|
|
|
const char *inoutstr = argv[1];
|
2015-09-03 01:41:21 +02:00
|
|
|
long int idx = strtol(argv[2], NULL, 10);
|
2014-08-04 07:56:43 +02:00
|
|
|
|
2015-09-03 01:41:21 +02:00
|
|
|
if ((idx == 0 && strcmp(argv[2], "0")) || idx >= MAX_FILES || idx < 0) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid file ID.");
|
2014-08-04 07:56:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
struct FileTransfer *ft = NULL;
|
2014-08-04 07:56:43 +02:00
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
/* cancel an incoming file transfer */
|
|
|
|
if (strcasecmp(inoutstr, "in") == 0) {
|
|
|
|
ft = get_file_transfer_struct_index(self->num, idx, FILE_TRANSFER_RECV);
|
|
|
|
} else if (strcasecmp(inoutstr, "out") == 0) {
|
|
|
|
ft = get_file_transfer_struct_index(self->num, idx, FILE_TRANSFER_SEND);
|
|
|
|
} else {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type must be 'in' or 'out'.");
|
2014-08-04 20:35:34 +02:00
|
|
|
return;
|
2015-03-30 00:33:51 +02:00
|
|
|
}
|
2014-08-04 07:56:43 +02:00
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
if (!ft) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid file ID.");
|
2014-08-04 20:35:34 +02:00
|
|
|
return;
|
2015-03-30 00:33:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ft->state == FILE_TRANSFER_INACTIVE) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid file ID.");
|
2014-08-04 20:35:34 +02:00
|
|
|
return;
|
2014-08-04 07:56:43 +02:00
|
|
|
}
|
2015-03-30 00:33:51 +02:00
|
|
|
|
2015-07-04 07:19:16 +02:00
|
|
|
snprintf(msg, sizeof(msg), "File transfer for '%s' aborted.", ft->file_name);
|
2015-03-30 00:33:51 +02:00
|
|
|
close_file_transfer(self, m, ft, TOX_FILE_CONTROL_CANCEL, msg, silent);
|
2014-08-04 07:56:43 +02:00
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
void cmd_conference_invite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
2013-11-10 03:43:56 +01:00
|
|
|
{
|
2020-03-15 19:57:00 +01:00
|
|
|
UNUSED_VAR(window);
|
|
|
|
|
2013-11-10 03:43:56 +01:00
|
|
|
if (argc < 1) {
|
2020-11-08 16:08:24 +01:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference number required.");
|
2014-03-24 12:18:58 +01:00
|
|
|
return;
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
long int conferencenum = strtol(argv[1], NULL, 10);
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
if ((conferencenum == 0 && strcmp(argv[1], "0")) || conferencenum < 0 || conferencenum == LONG_MAX) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid conference number.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_Err_Conference_Invite err;
|
2016-12-18 06:01:51 +01:00
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
if (!tox_conference_invite(m, self->num, conferencenum, &err)) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to invite contact to conference (error %d)", err);
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invited contact to Conference %ld.", conferencenum);
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
void cmd_conference_join(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
2013-11-10 03:43:56 +01:00
|
|
|
{
|
2020-03-15 19:57:00 +01:00
|
|
|
UNUSED_VAR(window);
|
|
|
|
UNUSED_VAR(argc);
|
|
|
|
UNUSED_VAR(argv);
|
|
|
|
|
2014-03-07 01:39:57 +01:00
|
|
|
if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, RED, " * Warning: Too many windows are open.");
|
2013-11-27 04:15:48 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
const char *conferencekey = Friends.list[self->num].conference_invite.key;
|
|
|
|
uint16_t length = Friends.list[self->num].conference_invite.length;
|
|
|
|
uint8_t type = Friends.list[self->num].conference_invite.type;
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
if (!Friends.list[self->num].conference_invite.pending) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending conference invite.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
uint32_t conferencenum;
|
|
|
|
|
|
|
|
if (type == TOX_CONFERENCE_TYPE_TEXT) {
|
|
|
|
Tox_Err_Conference_Join err;
|
|
|
|
conferencenum = tox_conference_join(m, self->num, (const uint8_t *) conferencekey, length, &err);
|
|
|
|
|
|
|
|
if (err != TOX_ERR_CONFERENCE_JOIN_OK) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference instance failed to initialize (error %d)", err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (type == TOX_CONFERENCE_TYPE_AV) {
|
|
|
|
#ifdef AUDIO
|
|
|
|
conferencenum = toxav_join_av_groupchat(m, self->num, (const uint8_t *) conferencekey, length, audio_conference_callback, NULL);
|
|
|
|
|
|
|
|
if (conferencenum == (uint32_t) -1) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Audio conference instance failed to initialize");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Audio support disabled by compile-time option.");
|
2016-12-18 06:01:51 +01:00
|
|
|
return;
|
2020-05-07 02:00:00 +02:00
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Unknown conference type %d", type);
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
if (init_conference_win(m, conferencenum, type, NULL, 0) == -1) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference window failed to initialize.");
|
|
|
|
tox_conference_delete(m, conferencenum, NULL);
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-11-12 02:49:05 +01:00
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
#ifdef AUDIO
|
|
|
|
|
|
|
|
if (type == TOX_CONFERENCE_TYPE_AV) {
|
|
|
|
if (!init_conference_audio_input(m, conferencenum)) {
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Audio capture failed; use \"/audio on\" to try again.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-19 21:32:35 +01:00
|
|
|
void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
2013-11-10 03:43:56 +01:00
|
|
|
{
|
2020-03-15 19:57:00 +01:00
|
|
|
UNUSED_VAR(window);
|
|
|
|
|
2014-08-04 20:35:34 +02:00
|
|
|
if (argc < 1) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File ID required.");
|
2014-04-19 23:58:13 +02:00
|
|
|
return;
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 01:41:21 +02:00
|
|
|
long int idx = strtol(argv[1], NULL, 10);
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2015-09-03 01:41:21 +02:00
|
|
|
if ((idx == 0 && strcmp(argv[1], "0")) || idx < 0 || idx >= MAX_FILES) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending file transfers with that ID.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
struct FileTransfer *ft = get_file_transfer_struct_index(self->num, idx, FILE_TRANSFER_RECV);
|
|
|
|
|
|
|
|
if (!ft) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending file transfers with that ID.");
|
2015-03-30 00:33:51 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
if (ft->state != FILE_TRANSFER_PENDING) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending file transfers with that ID.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
if ((ft->file = fopen(ft->file_path, "a")) == NULL) {
|
2018-10-08 06:47:51 +02:00
|
|
|
const char *msg = "File transfer failed: Invalid download path.";
|
2015-03-30 00:33:51 +02:00
|
|
|
close_file_transfer(self, m, ft, TOX_FILE_CONTROL_CANCEL, msg, notif_error);
|
|
|
|
return;
|
|
|
|
}
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_Err_File_Control err;
|
2020-11-14 01:38:33 +01:00
|
|
|
tox_file_control(m, self->num, ft->filenumber, TOX_FILE_CONTROL_RESUME, &err);
|
2014-07-27 23:14:28 +02:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (err != TOX_ERR_FILE_CONTROL_OK) {
|
2015-03-28 07:56:54 +01:00
|
|
|
goto on_recv_error;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2014-03-05 09:31:12 +01:00
|
|
|
|
2020-11-03 03:15:32 +01:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Saving file [%ld] as: '%s'", idx, ft->file_path);
|
2015-03-28 07:56:54 +01:00
|
|
|
|
|
|
|
/* prep progress bar line */
|
|
|
|
char progline[MAX_STR_SIZE];
|
2015-08-18 21:12:48 +02:00
|
|
|
init_progress_bar(progline);
|
2015-03-28 07:56:54 +01:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", progline);
|
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
ft->line_id = self->chatwin->hst->line_end->id + 2;
|
|
|
|
ft->state = FILE_TRANSFER_STARTED;
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
on_recv_error:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
switch (err) {
|
|
|
|
case TOX_ERR_FILE_CONTROL_FRIEND_NOT_FOUND:
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer failed: Friend not found.");
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_CONTROL_FRIEND_NOT_CONNECTED:
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer failed: Friend is not online.");
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_CONTROL_NOT_FOUND:
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer failed: Invalid filenumber.");
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_CONTROL_SENDQ:
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer failed: Connection error.");
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer failed (error %d)\n", err);
|
2015-03-28 07:56:54 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-19 21:32:35 +01:00
|
|
|
void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
2013-11-10 03:43:56 +01:00
|
|
|
{
|
2020-03-15 19:57:00 +01:00
|
|
|
UNUSED_VAR(window);
|
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
const char *errmsg = NULL;
|
2013-11-10 03:43:56 +01:00
|
|
|
|
|
|
|
if (argc < 1) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File path required.");
|
2014-04-19 23:58:13 +02:00
|
|
|
return;
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2014-07-29 20:54:34 +02:00
|
|
|
char path[MAX_STR_SIZE];
|
2018-10-08 06:47:51 +02:00
|
|
|
snprintf(path, sizeof(path), "%s", argv[1]);
|
|
|
|
int path_len = strlen(path);
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2014-07-25 23:55:21 +02:00
|
|
|
if (path_len >= MAX_STR_SIZE) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File path exceeds character limit.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE *file_to_send = fopen(path, "r");
|
|
|
|
|
|
|
|
if (file_to_send == NULL) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File not found.");
|
2013-11-10 03:43:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-24 20:23:08 +02:00
|
|
|
off_t filesize = file_size(path);
|
2014-09-24 04:51:56 +02:00
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
if (filesize == 0) {
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid file.");
|
2014-09-24 04:51:56 +02:00
|
|
|
fclose(file_to_send);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
char file_name[TOX_MAX_FILENAME_LENGTH];
|
2015-03-30 00:33:51 +02:00
|
|
|
size_t namelen = get_file_name(file_name, sizeof(file_name), path);
|
2013-11-10 03:43:56 +01:00
|
|
|
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_Err_File_Send err;
|
2015-03-30 00:33:51 +02:00
|
|
|
uint32_t filenum = tox_file_send(m, self->num, TOX_FILE_KIND_DATA, (uint64_t) filesize, NULL,
|
2016-09-25 03:07:04 +02:00
|
|
|
(uint8_t *) file_name, namelen, &err);
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
if (err != TOX_ERR_FILE_SEND_OK) {
|
2015-03-28 07:56:54 +01:00
|
|
|
goto on_send_error;
|
2018-07-18 17:33:16 +02:00
|
|
|
}
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2015-08-18 21:12:48 +02:00
|
|
|
struct FileTransfer *ft = new_file_transfer(self, self->num, filenum, FILE_TRANSFER_SEND, TOX_FILE_KIND_DATA);
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
if (!ft) {
|
|
|
|
err = TOX_ERR_FILE_SEND_TOO_MANY;
|
2015-03-28 07:56:54 +01:00
|
|
|
goto on_send_error;
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|
|
|
|
|
2015-03-30 00:33:51 +02:00
|
|
|
memcpy(ft->file_name, file_name, namelen + 1);
|
|
|
|
ft->file = file_to_send;
|
|
|
|
ft->file_size = filesize;
|
2015-08-10 20:22:13 +02:00
|
|
|
tox_file_get_file_id(m, self->num, filenum, ft->file_id, NULL);
|
2015-03-28 07:56:54 +01:00
|
|
|
|
|
|
|
char sizestr[32];
|
|
|
|
bytes_convert_str(sizestr, sizeof(sizestr), filesize);
|
2015-07-04 07:19:16 +02:00
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Sending file [%d]: '%s' (%s)", filenum, file_name, sizestr);
|
2015-03-28 07:56:54 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
on_send_error:
|
2016-09-25 03:07:04 +02:00
|
|
|
|
2015-03-28 07:56:54 +01:00
|
|
|
switch (err) {
|
|
|
|
case TOX_ERR_FILE_SEND_FRIEND_NOT_FOUND:
|
2015-07-04 07:19:16 +02:00
|
|
|
errmsg = "File transfer failed: Invalid friend.";
|
2015-03-28 07:56:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_SEND_FRIEND_NOT_CONNECTED:
|
2015-07-04 07:19:16 +02:00
|
|
|
errmsg = "File transfer failed: Friend is offline.";
|
2015-03-28 07:56:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_SEND_NAME_TOO_LONG:
|
2015-07-04 07:19:16 +02:00
|
|
|
errmsg = "File transfer failed: Filename is too long.";
|
2015-03-28 07:56:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOX_ERR_FILE_SEND_TOO_MANY:
|
2015-07-04 07:19:16 +02:00
|
|
|
errmsg = "File transfer failed: Too many concurrent file transfers.";
|
2015-03-28 07:56:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2015-07-04 07:19:16 +02:00
|
|
|
errmsg = "File transfer failed.";
|
2015-03-28 07:56:54 +01:00
|
|
|
break;
|
2014-06-28 18:14:43 +02:00
|
|
|
}
|
2015-03-28 07:56:54 +01:00
|
|
|
|
|
|
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", errmsg);
|
|
|
|
tox_file_control(m, self->num, filenum, TOX_FILE_CONTROL_CANCEL, NULL);
|
|
|
|
fclose(file_to_send);
|
2013-11-10 03:43:56 +01:00
|
|
|
}
|