clang-format
This commit is contained in:
parent
4ca6ae3169
commit
d0ab7b0139
@ -19,21 +19,21 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
#include <weechat/weechat-plugin.h>
|
#include <weechat/weechat-plugin.h>
|
||||||
|
|
||||||
#include "twc-bootstrap.h"
|
#include "twc-bootstrap.h"
|
||||||
#include "twc-tfer.h"
|
|
||||||
#include "twc-chat.h"
|
#include "twc-chat.h"
|
||||||
#include "twc-config.h"
|
#include "twc-config.h"
|
||||||
#include "twc-friend-request.h"
|
#include "twc-friend-request.h"
|
||||||
#include "twc-group-invite.h"
|
#include "twc-group-invite.h"
|
||||||
#include "twc-list.h"
|
#include "twc-list.h"
|
||||||
#include "twc-profile.h"
|
#include "twc-profile.h"
|
||||||
|
#include "twc-tfer.h"
|
||||||
#include "twc-utils.h"
|
#include "twc-utils.h"
|
||||||
#include "twc.h"
|
#include "twc.h"
|
||||||
|
|
||||||
@ -52,8 +52,9 @@ enum TWC_FRIEND_MATCH
|
|||||||
#define TWC_CHECK_PROFILE(profile) \
|
#define TWC_CHECK_PROFILE(profile) \
|
||||||
if (!profile) \
|
if (!profile) \
|
||||||
{ \
|
{ \
|
||||||
weechat_printf(NULL, "%s%s: command \"%s\" must be executed on a Tox " \
|
weechat_printf(NULL, \
|
||||||
"buffer", \
|
"%s%s: command \"%s\" must be executed on a Tox " \
|
||||||
|
"buffer", \
|
||||||
weechat_prefix("error"), weechat_plugin->name, \
|
weechat_prefix("error"), weechat_plugin->name, \
|
||||||
argv[0]); \
|
argv[0]); \
|
||||||
return WEECHAT_RC_OK; \
|
return WEECHAT_RC_OK; \
|
||||||
@ -66,10 +67,11 @@ enum TWC_FRIEND_MATCH
|
|||||||
#define TWC_CHECK_CHAT(chat) \
|
#define TWC_CHECK_CHAT(chat) \
|
||||||
if (!chat) \
|
if (!chat) \
|
||||||
{ \
|
{ \
|
||||||
weechat_printf( \
|
weechat_printf(NULL, \
|
||||||
NULL, "%s%s: command \"%s\" must be executed in a chat " \
|
"%s%s: command \"%s\" must be executed in a chat " \
|
||||||
"buffer", \
|
"buffer", \
|
||||||
weechat_prefix("error"), weechat_plugin->name, argv[0]); \
|
weechat_prefix("error"), weechat_plugin->name, \
|
||||||
|
argv[0]); \
|
||||||
return WEECHAT_RC_OK; \
|
return WEECHAT_RC_OK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,10 +82,11 @@ enum TWC_FRIEND_MATCH
|
|||||||
#define TWC_CHECK_GROUP_CHAT(chat) \
|
#define TWC_CHECK_GROUP_CHAT(chat) \
|
||||||
if (!chat || chat->group_number < 0) \
|
if (!chat || chat->group_number < 0) \
|
||||||
{ \
|
{ \
|
||||||
weechat_printf( \
|
weechat_printf(NULL, \
|
||||||
NULL, "%s%s: command \"%s\" must be executed in a group " \
|
"%s%s: command \"%s\" must be executed in a group " \
|
||||||
"chat buffer ", \
|
"chat buffer ", \
|
||||||
weechat_prefix("error"), weechat_plugin->name, argv[0]); \
|
weechat_prefix("error"), weechat_plugin->name, \
|
||||||
|
argv[0]); \
|
||||||
return WEECHAT_RC_OK; \
|
return WEECHAT_RC_OK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +138,7 @@ enum TWC_FRIEND_MATCH
|
|||||||
* Make sure a file exists.
|
* Make sure a file exists.
|
||||||
*/
|
*/
|
||||||
#define TWC_CHECK_FILE_EXISTS(filename) \
|
#define TWC_CHECK_FILE_EXISTS(filename) \
|
||||||
if(access(filename, F_OK) == -1 ) \
|
if (access(filename, F_OK) == -1) \
|
||||||
{ \
|
{ \
|
||||||
weechat_printf(NULL, "%sFile \"%s\" does not exist", \
|
weechat_printf(NULL, "%sFile \"%s\" does not exist", \
|
||||||
weechat_prefix("error"), filename); \
|
weechat_prefix("error"), filename); \
|
||||||
@ -143,8 +146,10 @@ enum TWC_FRIEND_MATCH
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define TWC_RETURN_WITH_FILE_ERROR(filename, type) \
|
#define TWC_RETURN_WITH_FILE_ERROR(filename, type) \
|
||||||
weechat_printf(NULL, "%s\"%s\" must be a regular file or pipe, " \
|
weechat_printf(NULL, \
|
||||||
"not a %s", weechat_prefix("error"), filename, type); \
|
"%s\"%s\" must be a regular file or pipe, " \
|
||||||
|
"not a %s", \
|
||||||
|
weechat_prefix("error"), filename, type); \
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -503,8 +508,8 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
/* /friend requests */
|
/* /friend requests */
|
||||||
else if (argc == 2 && weechat_strcasecmp(argv[1], "requests") == 0)
|
else if (argc == 2 && weechat_strcasecmp(argv[1], "requests") == 0)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%sPending friend requests:",
|
weechat_printf(profile->buffer,
|
||||||
weechat_prefix("network"));
|
"%sPending friend requests:", weechat_prefix("network"));
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
@ -514,8 +519,9 @@ twc_cmd_friend(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
twc_bin2hex(item->friend_request->tox_id, TOX_PUBLIC_KEY_SIZE,
|
twc_bin2hex(item->friend_request->tox_id, TOX_PUBLIC_KEY_SIZE,
|
||||||
hex_address);
|
hex_address);
|
||||||
|
|
||||||
weechat_printf(profile->buffer, "%s[%d] Address: %s\n"
|
weechat_printf(profile->buffer,
|
||||||
"[%d] Message: %s",
|
"%s[%d] Address: %s\n"
|
||||||
|
"[%d] Message: %s",
|
||||||
weechat_prefix("network"), index, hex_address, index,
|
weechat_prefix("network"), index, hex_address, index,
|
||||||
item->friend_request->message);
|
item->friend_request->message);
|
||||||
}
|
}
|
||||||
@ -1142,8 +1148,9 @@ twc_cmd_tox(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
weechat_printf(NULL, "%s%s: You must confirm deletion with either "
|
weechat_printf(NULL,
|
||||||
"\"-keepdata\" or \"-yes\" (see /help tox)",
|
"%s%s: You must confirm deletion with either "
|
||||||
|
"\"-keepdata\" or \"-yes\" (see /help tox)",
|
||||||
weechat_prefix("error"), weechat_plugin->name);
|
weechat_prefix("error"), weechat_plugin->name);
|
||||||
return WEECHAT_RC_OK;
|
return WEECHAT_RC_OK;
|
||||||
}
|
}
|
||||||
@ -1200,7 +1207,7 @@ twc_cmd_tox(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
||||||
int argc, char **argv, char **argv_eol)
|
int argc, char **argv, char **argv_eol)
|
||||||
{
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
@ -1217,14 +1224,17 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
{
|
{
|
||||||
if (profile->buffer == buffer || profile->tfer->buffer == buffer)
|
if (profile->buffer == buffer || profile->tfer->buffer == buffer)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%s%s", weechat_prefix("error"), "you must specify a friend");
|
weechat_printf(profile->buffer, "%s%s", weechat_prefix("error"),
|
||||||
|
"you must specify a friend");
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
}
|
}
|
||||||
snprintf(recipient, TOX_MAX_NAME_LENGTH, "%s", weechat_buffer_get_string(buffer, "name"));
|
snprintf(recipient, TOX_MAX_NAME_LENGTH, "%s",
|
||||||
|
weechat_buffer_get_string(buffer, "name"));
|
||||||
struct t_twc_chat *chat = twc_chat_search_buffer(buffer);
|
struct t_twc_chat *chat = twc_chat_search_buffer(buffer);
|
||||||
if (chat->group_number != -1)
|
if (chat->group_number != -1)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%s%s", weechat_prefix("error"), "the file transmission is "
|
weechat_printf(profile->buffer, "%s%s", weechat_prefix("error"),
|
||||||
|
"the file transmission is "
|
||||||
"allowed only between friends");
|
"allowed only between friends");
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
}
|
}
|
||||||
@ -1238,11 +1248,12 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
/* /send <number>|<name>|<Tox ID> <file> */
|
/* /send <number>|<name>|<Tox ID> <file> */
|
||||||
if (argc >= 3)
|
if (argc >= 3)
|
||||||
{
|
{
|
||||||
/* do a shell split in case a friend has spaces in his name
|
/* do a shell split in case a friend has spaces in his name
|
||||||
* and join the name */
|
* and join the name */
|
||||||
int shell_argc;
|
int shell_argc;
|
||||||
char **shell_argv = weechat_string_split_shell(argv_eol[1], &shell_argc);
|
char **shell_argv =
|
||||||
for (int i = 0; i < shell_argc -1; i++)
|
weechat_string_split_shell(argv_eol[1], &shell_argc);
|
||||||
|
for (int i = 0; i < shell_argc - 1; i++)
|
||||||
{
|
{
|
||||||
strcat(recipient, shell_argv[i]);
|
strcat(recipient, shell_argv[i]);
|
||||||
if (i < shell_argc - 2)
|
if (i < shell_argc - 2)
|
||||||
@ -1258,7 +1269,7 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
TWC_CHECK_FILE_EXISTS(filename);
|
TWC_CHECK_FILE_EXISTS(filename);
|
||||||
|
|
||||||
uint32_t friend_number = twc_match_friend(profile, recipient);
|
uint32_t friend_number = twc_match_friend(profile, recipient);
|
||||||
TWC_CHECK_FRIEND_NUMBER(profile, (signed) friend_number, recipient);
|
TWC_CHECK_FRIEND_NUMBER(profile, (signed)friend_number, recipient);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
stat(filename, &st);
|
stat(filename, &st);
|
||||||
@ -1277,30 +1288,34 @@ twc_cmd_send(const void *pointer, void *data, struct t_gui_buffer *buffer,
|
|||||||
case S_IFLNK:
|
case S_IFLNK:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
weechat_printf(NULL, "%sunknown file type", weechat_prefix("error"));
|
weechat_printf(NULL, "%sunknown file type",
|
||||||
|
weechat_prefix("error"));
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *stripped_name = twc_tfer_file_name_strip(filename, FILENAME_MAX + 1 - strlen(filename));
|
char *stripped_name =
|
||||||
|
twc_tfer_file_name_strip(filename, FILENAME_MAX + 1 - strlen(filename));
|
||||||
|
|
||||||
TOX_ERR_FILE_SEND error;
|
TOX_ERR_FILE_SEND error;
|
||||||
uint32_t file_number = tox_file_send(profile->tox, friend_number, TOX_FILE_KIND_DATA,
|
uint32_t file_number =
|
||||||
S_ISFIFO(st.st_mode) ? UINT64_MAX : (size_t)st.st_size,
|
tox_file_send(profile->tox, friend_number, TOX_FILE_KIND_DATA,
|
||||||
NULL, (uint8_t *)stripped_name, strlen(filename), &error);
|
S_ISFIFO(st.st_mode) ? UINT64_MAX : (size_t)st.st_size,
|
||||||
|
NULL, (uint8_t *)stripped_name, strlen(filename), &error);
|
||||||
free(stripped_name);
|
free(stripped_name);
|
||||||
if (error != TOX_ERR_FILE_SEND_OK)
|
if (error != TOX_ERR_FILE_SEND_OK)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %s",
|
weechat_printf(profile->buffer, "%ssending \"%s\" has been failed: %s",
|
||||||
weechat_prefix("error"), filename, twc_tox_err_file_send(error));
|
weechat_prefix("error"), filename,
|
||||||
|
twc_tox_err_file_send(error));
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
}
|
}
|
||||||
if (!(profile->tfer->buffer))
|
if (!(profile->tfer->buffer))
|
||||||
{
|
{
|
||||||
twc_tfer_load(profile);
|
twc_tfer_load(profile);
|
||||||
}
|
}
|
||||||
struct t_twc_tfer_file *file = twc_tfer_file_new(profile, recipient, filename,
|
struct t_twc_tfer_file *file = twc_tfer_file_new(
|
||||||
friend_number, file_number,
|
profile, recipient, filename, friend_number, file_number, st.st_size,
|
||||||
st.st_size, TWC_TFER_FILE_TYPE_UPLOADING);
|
TWC_TFER_FILE_TYPE_UPLOADING);
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%scannot open the file \"%s\"",
|
weechat_printf(profile->buffer, "%scannot open the file \"%s\"",
|
||||||
@ -1347,10 +1362,11 @@ twc_commands_init()
|
|||||||
" || decline",
|
" || decline",
|
||||||
twc_cmd_friend, NULL, NULL);
|
twc_cmd_friend, NULL, NULL);
|
||||||
|
|
||||||
weechat_hook_command("group", "manage group chats", "create"
|
weechat_hook_command("group", "manage group chats",
|
||||||
" || invites"
|
"create"
|
||||||
" || join <number>"
|
" || invites"
|
||||||
" || decline <number>",
|
" || join <number>"
|
||||||
|
" || decline <number>",
|
||||||
" create: create a new group chat\n"
|
" create: create a new group chat\n"
|
||||||
"invites: list group chat invites\n"
|
"invites: list group chat invites\n"
|
||||||
" join: join a group chat by its invite ID\n"
|
" join: join a group chat by its invite ID\n"
|
||||||
@ -1416,12 +1432,13 @@ twc_commands_init()
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
weechat_hook_command(
|
weechat_hook_command(
|
||||||
"tox", "manage Tox profiles", "list"
|
"tox", "manage Tox profiles",
|
||||||
" || create <name>"
|
"list"
|
||||||
" || delete <name> -yes|-keepdata"
|
" || create <name>"
|
||||||
" || load [<name>...]"
|
" || delete <name> -yes|-keepdata"
|
||||||
" || unload [<name>...]"
|
" || load [<name>...]"
|
||||||
" || reload [<name>...]",
|
" || unload [<name>...]"
|
||||||
|
" || reload [<name>...]",
|
||||||
" list: list all Tox profile\n"
|
" list: list all Tox profile\n"
|
||||||
"create: create a new Tox profile\n"
|
"create: create a new Tox profile\n"
|
||||||
"delete: delete a Tox profile; requires either -yes "
|
"delete: delete a Tox profile; requires either -yes "
|
||||||
@ -1437,12 +1454,13 @@ twc_commands_init()
|
|||||||
" || unload %(tox_loaded_profiles)|%*"
|
" || unload %(tox_loaded_profiles)|%*"
|
||||||
" || reload %(tox_loaded_profiles)|%*",
|
" || reload %(tox_loaded_profiles)|%*",
|
||||||
twc_cmd_tox, NULL, NULL);
|
twc_cmd_tox, NULL, NULL);
|
||||||
weechat_hook_command("send", "send a file to a friend",
|
weechat_hook_command(
|
||||||
"<file>"
|
"send", "send a file to a friend",
|
||||||
" || <number>|<name>|<Tox ID> <file>",
|
"<file>"
|
||||||
"file: path to the file\n"
|
" || <number>|<name>|<Tox ID> <file>",
|
||||||
"number, name, Tox ID: the friend you are sending the file to\n",
|
"file: path to the file\n"
|
||||||
"%(filename)"
|
"number, name, Tox ID: the friend you are sending the file to\n",
|
||||||
" || %(tox_friend_name)|%(tox_friend_tox_id) %(filename)",
|
"%(filename)"
|
||||||
twc_cmd_send, NULL, NULL);
|
" || %(tox_friend_name)|%(tox_friend_tox_id) %(filename)",
|
||||||
|
twc_cmd_send, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,19 @@ struct t_config_option *twc_config_friend_request_message;
|
|||||||
struct t_config_option *twc_config_short_id_size;
|
struct t_config_option *twc_config_short_id_size;
|
||||||
|
|
||||||
char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] = {
|
char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] = {
|
||||||
"save_file", "autoload", "autojoin", "autojoin_delay",
|
"save_file",
|
||||||
"max_friend_requests", "proxy_address", "proxy_port", "proxy_type",
|
"autoload",
|
||||||
"udp", "ipv6", "passphrase", "logging", "downloading_path",
|
"autojoin",
|
||||||
|
"autojoin_delay",
|
||||||
|
"max_friend_requests",
|
||||||
|
"proxy_address",
|
||||||
|
"proxy_port",
|
||||||
|
"proxy_type",
|
||||||
|
"udp",
|
||||||
|
"ipv6",
|
||||||
|
"passphrase",
|
||||||
|
"logging",
|
||||||
|
"downloading_path",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,9 +237,10 @@ twc_config_init_option(struct t_twc_profile *profile,
|
|||||||
break;
|
break;
|
||||||
case TWC_PROFILE_OPTION_AUTOJOIN_DELAY:
|
case TWC_PROFILE_OPTION_AUTOJOIN_DELAY:
|
||||||
type = "integer";
|
type = "integer";
|
||||||
description = "delay befor do autojoin (in ms) this required to "
|
description =
|
||||||
"tox from entering incorrect state and stop processing "
|
"delay befor do autojoin (in ms) this required to "
|
||||||
"group events";
|
"tox from entering incorrect state and stop processing "
|
||||||
|
"group events";
|
||||||
min = 0;
|
min = 0;
|
||||||
max = INT_MAX;
|
max = INT_MAX;
|
||||||
default_value = "5000";
|
default_value = "5000";
|
||||||
@ -291,8 +302,9 @@ twc_config_init_option(struct t_twc_profile *profile,
|
|||||||
break;
|
break;
|
||||||
case TWC_PROFILE_OPTION_DOWNLOADING_PATH:
|
case TWC_PROFILE_OPTION_DOWNLOADING_PATH:
|
||||||
type = "string";
|
type = "string";
|
||||||
description = "path to downloaded files (\"%h\" will be replaced by "
|
description =
|
||||||
"WeeChat home folder and \"%p\" by profile name";
|
"path to downloaded files (\"%h\" will be replaced by "
|
||||||
|
"WeeChat home folder and \"%p\" by profile name";
|
||||||
default_value = "%h/tfer/%p/";
|
default_value = "%h/tfer/%p/";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -58,7 +58,8 @@ twc_group_chat_invite_add(struct t_twc_profile *profile, int32_t friend_number,
|
|||||||
invite->data_size = size;
|
invite->data_size = size;
|
||||||
|
|
||||||
if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN))
|
if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN))
|
||||||
invite->autojoin_delay = TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_AUTOJOIN_DELAY);
|
invite->autojoin_delay = TWC_PROFILE_OPTION_INTEGER(
|
||||||
|
profile, TWC_PROFILE_OPTION_AUTOJOIN_DELAY);
|
||||||
else
|
else
|
||||||
invite->autojoin_delay = 0;
|
invite->autojoin_delay = 0;
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#ifndef TOX_WEECHAT_LIST_H
|
#ifndef TOX_WEECHAT_LIST_H
|
||||||
#define TOX_WEECHAT_LIST_H
|
#define TOX_WEECHAT_LIST_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "twc-tfer.h"
|
#include "twc-tfer.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct t_twc_list
|
struct t_twc_list
|
||||||
{
|
{
|
||||||
|
@ -257,8 +257,9 @@ twc_tox_new_print_error(struct t_twc_profile *profile,
|
|||||||
weechat_prefix("error"), options->proxy_host);
|
weechat_prefix("error"), options->proxy_host);
|
||||||
break;
|
break;
|
||||||
case TOX_ERR_NEW_LOAD_ENCRYPTED:
|
case TOX_ERR_NEW_LOAD_ENCRYPTED:
|
||||||
weechat_printf(profile->buffer, "%scould not load Tox (encrypted "
|
weechat_printf(profile->buffer,
|
||||||
"data files are not yet supported)",
|
"%scould not load Tox (encrypted "
|
||||||
|
"data files are not yet supported)",
|
||||||
weechat_prefix("error"));
|
weechat_prefix("error"));
|
||||||
break;
|
break;
|
||||||
case TOX_ERR_NEW_LOAD_BAD_FORMAT:
|
case TOX_ERR_NEW_LOAD_BAD_FORMAT:
|
||||||
@ -394,7 +395,8 @@ twc_profile_load(struct t_twc_profile *profile)
|
|||||||
{
|
{
|
||||||
weechat_printf(profile->buffer,
|
weechat_printf(profile->buffer,
|
||||||
"%scould not decrypt Tox data file (no passphrase "
|
"%scould not decrypt Tox data file (no passphrase "
|
||||||
"specified)", weechat_prefix("error"));
|
"specified)",
|
||||||
|
weechat_prefix("error"));
|
||||||
return TWC_RC_ERROR;
|
return TWC_RC_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,13 +455,15 @@ twc_profile_load(struct t_twc_profile *profile)
|
|||||||
tox_callback_friend_request(profile->tox, twc_friend_request_callback);
|
tox_callback_friend_request(profile->tox, twc_friend_request_callback);
|
||||||
tox_callback_conference_invite(profile->tox, twc_group_invite_callback);
|
tox_callback_conference_invite(profile->tox, twc_group_invite_callback);
|
||||||
tox_callback_conference_message(profile->tox, twc_group_message_callback);
|
tox_callback_conference_message(profile->tox, twc_group_message_callback);
|
||||||
tox_callback_conference_peer_list_changed(profile->tox,
|
tox_callback_conference_peer_list_changed(
|
||||||
twc_group_peer_list_changed_callback);
|
profile->tox, twc_group_peer_list_changed_callback);
|
||||||
tox_callback_conference_peer_name(profile->tox,
|
tox_callback_conference_peer_name(profile->tox,
|
||||||
twc_group_peer_name_callback);
|
twc_group_peer_name_callback);
|
||||||
tox_callback_conference_title(profile->tox, twc_group_title_callback);
|
tox_callback_conference_title(profile->tox, twc_group_title_callback);
|
||||||
tox_callback_file_recv_control(profile->tox, twc_file_recv_control_callback);
|
tox_callback_file_recv_control(profile->tox,
|
||||||
tox_callback_file_chunk_request(profile->tox, twc_file_chunk_request_callback);
|
twc_file_recv_control_callback);
|
||||||
|
tox_callback_file_chunk_request(profile->tox,
|
||||||
|
twc_file_chunk_request_callback);
|
||||||
tox_callback_file_recv(profile->tox, twc_file_recv_callback);
|
tox_callback_file_recv(profile->tox, twc_file_recv_callback);
|
||||||
tox_callback_file_recv_chunk(profile->tox, twc_file_recv_chunk_callback);
|
tox_callback_file_recv_chunk(profile->tox, twc_file_recv_chunk_callback);
|
||||||
|
|
||||||
@ -597,7 +601,7 @@ twc_profile_search_tox(struct Tox *tox)
|
|||||||
{
|
{
|
||||||
size_t profile_index;
|
size_t profile_index;
|
||||||
struct t_twc_list_item *profile_item;
|
struct t_twc_list_item *profile_item;
|
||||||
twc_list_foreach(twc_profiles, profile_index, profile_item)
|
twc_list_foreach (twc_profiles, profile_index, profile_item)
|
||||||
{
|
{
|
||||||
if (profile_item->profile->tox == tox)
|
if (profile_item->profile->tox == tox)
|
||||||
return profile_item->profile;
|
return profile_item->profile;
|
||||||
@ -685,7 +689,8 @@ twc_profile_free(struct t_twc_profile *profile)
|
|||||||
/* close tfer's buffer */
|
/* close tfer's buffer */
|
||||||
if (profile->tfer->buffer)
|
if (profile->tfer->buffer)
|
||||||
{
|
{
|
||||||
weechat_buffer_set_pointer(profile->tfer->buffer, "close_callback", NULL);
|
weechat_buffer_set_pointer(profile->tfer->buffer, "close_callback",
|
||||||
|
NULL);
|
||||||
weechat_buffer_close(profile->tfer->buffer);
|
weechat_buffer_close(profile->tfer->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
260
src/twc-tfer.c
260
src/twc-tfer.c
@ -17,43 +17,52 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
#include <weechat/weechat-plugin.h>
|
#include <weechat/weechat-plugin.h>
|
||||||
|
|
||||||
#include "twc-tfer.h"
|
|
||||||
#include "twc-profile.h"
|
|
||||||
#include "twc-list.h"
|
#include "twc-list.h"
|
||||||
|
#include "twc-profile.h"
|
||||||
|
#include "twc-tfer.h"
|
||||||
#include "twc-utils.h"
|
#include "twc-utils.h"
|
||||||
#include "twc.h"
|
#include "twc.h"
|
||||||
|
|
||||||
#define PROGRESS_BAR_LEN (50)
|
#define PROGRESS_BAR_LEN (50)
|
||||||
|
|
||||||
#define TWC_TFER_UPDATE_STATUS_AND_RETURN(fmt, ...) {\
|
#define TWC_TFER_UPDATE_STATUS_AND_RETURN(fmt, ...) \
|
||||||
sprintf(status, fmt, ##__VA_ARGS__); \
|
do \
|
||||||
twc_tfer_update_status(profile->tfer, status); \
|
{ \
|
||||||
weechat_string_free_split(argv); \
|
sprintf(status, fmt, ##__VA_ARGS__); \
|
||||||
free(status); \
|
twc_tfer_update_status(profile->tfer, status); \
|
||||||
return WEECHAT_RC_OK; \
|
weechat_string_free_split(argv); \
|
||||||
}
|
free(status); \
|
||||||
|
return WEECHAT_RC_OK; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TWC_TFER_MESSAGE(present, past) {\
|
#define TWC_TFER_MESSAGE(present, past) \
|
||||||
int result = twc_tfer_file_ ## present(profile, n); \
|
do \
|
||||||
switch (result) \
|
{ \
|
||||||
{ \
|
int result = twc_tfer_file_##present(profile, n); \
|
||||||
case 1: \
|
switch (result) \
|
||||||
TWC_TFER_UPDATE_STATUS_AND_RETURN("request number %ld has been " #past, n); \
|
{ \
|
||||||
case 0: \
|
case 1: \
|
||||||
TWC_TFER_UPDATE_STATUS_AND_RETURN("request number %ld cannot be " #past " because " \
|
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
|
||||||
"of tox internal issues", n); \
|
"request number %ld has been " #past, n); \
|
||||||
case -1: \
|
case 0: \
|
||||||
TWC_TFER_UPDATE_STATUS_AND_RETURN("request number %ld cannot be " #past, n); \
|
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
|
||||||
} }\
|
"request number %ld cannot be " #past " because " \
|
||||||
|
"of tox internal issues", \
|
||||||
|
n); \
|
||||||
|
case -1: \
|
||||||
|
TWC_TFER_UPDATE_STATUS_AND_RETURN( \
|
||||||
|
"request number %ld cannot be " #past, n); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new "tfer" object that handles a list of transmitting files and
|
* Create a new "tfer" object that handles a list of transmitting files and
|
||||||
* a buffer for managing them.
|
* a buffer for managing them.
|
||||||
*/
|
*/
|
||||||
struct t_twc_tfer *
|
struct t_twc_tfer *
|
||||||
@ -76,11 +85,9 @@ twc_tfer_load(struct t_twc_profile *profile)
|
|||||||
struct t_gui_buffer *buffer;
|
struct t_gui_buffer *buffer;
|
||||||
char *name = malloc(sizeof(profile->name) + 5);
|
char *name = malloc(sizeof(profile->name) + 5);
|
||||||
sprintf(name, "tfer/%s", profile->name);
|
sprintf(name, "tfer/%s", profile->name);
|
||||||
profile->tfer->buffer = buffer = weechat_buffer_new(name,
|
profile->tfer->buffer = buffer = weechat_buffer_new(
|
||||||
twc_tfer_buffer_input_callback,
|
name, twc_tfer_buffer_input_callback, (void *)profile, NULL,
|
||||||
(void *)profile, NULL,
|
twc_tfer_buffer_close_callback, (void *)profile, NULL);
|
||||||
twc_tfer_buffer_close_callback,
|
|
||||||
(void *)profile, NULL);
|
|
||||||
free(name);
|
free(name);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return TWC_RC_ERROR;
|
return TWC_RC_ERROR;
|
||||||
@ -104,9 +111,7 @@ twc_tfer_print_legend(struct t_twc_tfer *tfer)
|
|||||||
char *text[TWC_TFER_LEGEND_LINES] = {
|
char *text[TWC_TFER_LEGEND_LINES] = {
|
||||||
"status: OK", /* This line is reserved for the status */
|
"status: OK", /* This line is reserved for the status */
|
||||||
"r: refresh | a <n>: accept | d <n>: decline",
|
"r: refresh | a <n>: accept | d <n>: decline",
|
||||||
"p <n>: pause | c <n>: continue | b <n>: abort",
|
"p <n>: pause | c <n>: continue | b <n>: abort", "files:"};
|
||||||
"files:"
|
|
||||||
};
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < TWC_TFER_LEGEND_LINES; i++)
|
for (i = 0; i < TWC_TFER_LEGEND_LINES; i++)
|
||||||
{
|
{
|
||||||
@ -132,23 +137,26 @@ twc_tfer_expanded_path(struct t_twc_profile *profile, const char *base_path)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set profile-associated path for downloads.
|
* Set profile-associated path for downloads.
|
||||||
* If it is impossible to create a directory with the path that
|
* If it is impossible to create a directory with the path that
|
||||||
* has been set in tox.profile.<name>.downloading_path then default
|
* has been set in tox.profile.<name>.downloading_path then default
|
||||||
* value will be used.
|
* value will be used.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
twc_tfer_update_downloading_path(struct t_twc_profile *profile)
|
twc_tfer_update_downloading_path(struct t_twc_profile *profile)
|
||||||
{
|
{
|
||||||
const char *base_path = TWC_PROFILE_OPTION_STRING(profile,
|
const char *base_path =
|
||||||
TWC_PROFILE_OPTION_DOWNLOADING_PATH);
|
TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_DOWNLOADING_PATH);
|
||||||
char *full_path = twc_tfer_expanded_path(profile, base_path);
|
char *full_path = twc_tfer_expanded_path(profile, base_path);
|
||||||
if (!weechat_mkdir_parents(full_path, 0755))
|
if (!weechat_mkdir_parents(full_path, 0755))
|
||||||
{
|
{
|
||||||
char *bad_path = full_path;
|
char *bad_path = full_path;
|
||||||
base_path = weechat_config_string(twc_config_profile_default[TWC_PROFILE_OPTION_DOWNLOADING_PATH]);
|
base_path = weechat_config_string(
|
||||||
|
twc_config_profile_default[TWC_PROFILE_OPTION_DOWNLOADING_PATH]);
|
||||||
full_path = twc_tfer_expanded_path(profile, base_path);
|
full_path = twc_tfer_expanded_path(profile, base_path);
|
||||||
weechat_printf(profile->buffer, "cannot create directory \"%s\","
|
weechat_printf(profile->buffer,
|
||||||
"using default value: \"%s\"", bad_path, full_path);
|
"cannot create directory \"%s\","
|
||||||
|
"using default value: \"%s\"",
|
||||||
|
bad_path, full_path);
|
||||||
free(bad_path);
|
free(bad_path);
|
||||||
weechat_mkdir_parents(full_path, 0755);
|
weechat_mkdir_parents(full_path, 0755);
|
||||||
}
|
}
|
||||||
@ -170,7 +178,7 @@ twc_tfer_file_check(const char *filename)
|
|||||||
* Returns a pointer to allocated string and must be freed after use.
|
* Returns a pointer to allocated string and must be freed after use.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
twc_tfer_file_unique_name(const char* original)
|
twc_tfer_file_unique_name(const char *original)
|
||||||
{
|
{
|
||||||
char *name = malloc(sizeof(char) * (FILENAME_MAX + 1));
|
char *name = malloc(sizeof(char) * (FILENAME_MAX + 1));
|
||||||
name[FILENAME_MAX] = '\0';
|
name[FILENAME_MAX] = '\0';
|
||||||
@ -189,7 +197,7 @@ twc_tfer_file_unique_name(const char* original)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
extension = "";
|
extension = "";
|
||||||
char body[strlen(name)+1];
|
char body[strlen(name) + 1];
|
||||||
strcpy(body, name);
|
strcpy(body, name);
|
||||||
|
|
||||||
/* check if there is already a postfix number in the end of the file
|
/* check if there is already a postfix number in the end of the file
|
||||||
@ -214,8 +222,7 @@ twc_tfer_file_unique_name(const char* original)
|
|||||||
{
|
{
|
||||||
snprintf(name, FILENAME_MAX, "%s(%i)%s", body, i, extension);
|
snprintf(name, FILENAME_MAX, "%s(%i)%s", body, i, extension);
|
||||||
i++;
|
i++;
|
||||||
}
|
} while (twc_tfer_file_check(name));
|
||||||
while (twc_tfer_file_check(name));
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -244,10 +251,10 @@ twc_tfer_file_name_strip(const char *original, size_t size)
|
|||||||
* Create a new file.
|
* Create a new file.
|
||||||
*/
|
*/
|
||||||
struct t_twc_tfer_file *
|
struct t_twc_tfer_file *
|
||||||
twc_tfer_file_new(struct t_twc_profile *profile,
|
twc_tfer_file_new(struct t_twc_profile *profile, const char *nickname,
|
||||||
const char *nickname, const char *filename,
|
const char *filename, uint32_t friend_number,
|
||||||
uint32_t friend_number, uint32_t file_number,
|
uint32_t file_number, uint64_t size,
|
||||||
uint64_t size, enum t_twc_tfer_file_type filetype)
|
enum t_twc_tfer_file_type filetype)
|
||||||
{
|
{
|
||||||
struct t_twc_tfer_file *file = malloc(sizeof(struct t_twc_tfer_file));
|
struct t_twc_tfer_file *file = malloc(sizeof(struct t_twc_tfer_file));
|
||||||
file->status = TWC_TFER_FILE_STATUS_REQUEST;
|
file->status = TWC_TFER_FILE_STATUS_REQUEST;
|
||||||
@ -264,8 +271,8 @@ twc_tfer_file_new(struct t_twc_profile *profile,
|
|||||||
{
|
{
|
||||||
char *full_path = malloc(sizeof(char) * (FILENAME_MAX + 1));
|
char *full_path = malloc(sizeof(char) * (FILENAME_MAX + 1));
|
||||||
sprintf(full_path, "%s", profile->tfer->downloading_path);
|
sprintf(full_path, "%s", profile->tfer->downloading_path);
|
||||||
char *final_name = twc_tfer_file_name_strip(filename,
|
char *final_name = twc_tfer_file_name_strip(
|
||||||
FILENAME_MAX + 1 - strlen(full_path));
|
filename, FILENAME_MAX + 1 - strlen(full_path));
|
||||||
if (!final_name)
|
if (!final_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -286,8 +293,8 @@ twc_tfer_file_new(struct t_twc_profile *profile,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file->filename = twc_tfer_file_name_strip(filename,
|
file->filename = twc_tfer_file_name_strip(
|
||||||
FILENAME_MAX + 1 - strlen(filename));
|
filename, FILENAME_MAX + 1 - strlen(filename));
|
||||||
file->full_path = NULL;
|
file->full_path = NULL;
|
||||||
file->fp = fopen(filename, "r");
|
file->fp = fopen(filename, "r");
|
||||||
}
|
}
|
||||||
@ -295,7 +302,6 @@ twc_tfer_file_new(struct t_twc_profile *profile,
|
|||||||
if (!(file->fp))
|
if (!(file->fp))
|
||||||
return NULL;
|
return NULL;
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,14 +328,8 @@ twc_tfer_file_get_type_str(struct t_twc_tfer_file *file)
|
|||||||
const char *
|
const char *
|
||||||
twc_tfer_file_get_status_str(struct t_twc_tfer_file *file)
|
twc_tfer_file_get_status_str(struct t_twc_tfer_file *file)
|
||||||
{
|
{
|
||||||
char *statuses[] = {
|
char *statuses[] = {"[request]", "", "[paused]",
|
||||||
"[request]",
|
"[done]", "[declined]", "[aborted]"};
|
||||||
"",
|
|
||||||
"[paused]",
|
|
||||||
"[done]",
|
|
||||||
"[declined]",
|
|
||||||
"[aborted]"
|
|
||||||
};
|
|
||||||
return statuses[file->status];
|
return statuses[file->status];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ twc_tfer_cut_size(size_t size)
|
|||||||
{
|
{
|
||||||
float ret = size;
|
float ret = size;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while((ret>1024) && (i < TWC_MAX_SIZE_SUFFIX))
|
while ((ret > 1024) && (i < TWC_MAX_SIZE_SUFFIX))
|
||||||
{
|
{
|
||||||
ret /= 1024.0;
|
ret /= 1024.0;
|
||||||
i++;
|
i++;
|
||||||
@ -358,7 +358,7 @@ twc_tfer_size_suffix(uint64_t size)
|
|||||||
char *suffixes[] = {"", "K", "M", "G", "T"};
|
char *suffixes[] = {"", "K", "M", "G", "T"};
|
||||||
uint64_t ret = size;
|
uint64_t ret = size;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while((ret > 1024) && (i < TWC_MAX_SIZE_SUFFIX))
|
while ((ret > 1024) && (i < TWC_MAX_SIZE_SUFFIX))
|
||||||
{
|
{
|
||||||
ret /= 1024.0;
|
ret /= 1024.0;
|
||||||
i++;
|
i++;
|
||||||
@ -374,7 +374,7 @@ twc_tfer_cut_speed(float speed)
|
|||||||
{
|
{
|
||||||
float ret = speed;
|
float ret = speed;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while((ret>1024) && (i < TWC_MAX_SPEED_SUFFIX))
|
while ((ret > 1024) && (i < TWC_MAX_SPEED_SUFFIX))
|
||||||
{
|
{
|
||||||
ret /= 1024.0;
|
ret /= 1024.0;
|
||||||
i++;
|
i++;
|
||||||
@ -391,7 +391,7 @@ twc_tfer_speed_suffix(float speed)
|
|||||||
char *suffixes[] = {"bytes/s", "KB/s", "MB/s", "GB/s", "TB/s"};
|
char *suffixes[] = {"bytes/s", "KB/s", "MB/s", "GB/s", "TB/s"};
|
||||||
uint64_t ret = speed;
|
uint64_t ret = speed;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while((ret > 1024) && (i < TWC_MAX_SPEED_SUFFIX))
|
while ((ret > 1024) && (i < TWC_MAX_SPEED_SUFFIX))
|
||||||
{
|
{
|
||||||
ret /= 1024.0;
|
ret /= 1024.0;
|
||||||
i++;
|
i++;
|
||||||
@ -407,7 +407,7 @@ twc_tfer_get_time()
|
|||||||
{
|
{
|
||||||
struct timespec tp;
|
struct timespec tp;
|
||||||
clock_gettime(CLOCK_REALTIME, &tp);
|
clock_gettime(CLOCK_REALTIME, &tp);
|
||||||
return (double)tp.tv_sec + (double)(tp.tv_nsec/1E9);
|
return (double)tp.tv_sec + (double)(tp.tv_nsec / 1E9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -441,8 +441,7 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
|
|||||||
{
|
{
|
||||||
remainder = remainder / 10;
|
remainder = remainder / 10;
|
||||||
indent++;
|
indent++;
|
||||||
}
|
} while (remainder > 0);
|
||||||
while (remainder > 0);
|
|
||||||
indent += 5; /* length of ") => " */
|
indent += 5; /* length of ") => " */
|
||||||
char placeholder[indent + 1];
|
char placeholder[indent + 1];
|
||||||
memset(placeholder, ' ', indent);
|
memset(placeholder, ' ', indent);
|
||||||
@ -450,21 +449,16 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
|
|||||||
const char *status = twc_tfer_file_get_status_str(file);
|
const char *status = twc_tfer_file_get_status_str(file);
|
||||||
if (file->size == UINT64_MAX)
|
if (file->size == UINT64_MAX)
|
||||||
{
|
{
|
||||||
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s [STREAM]",
|
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s [STREAM]", index,
|
||||||
index, type, file->nickname, file->filename);
|
type, file->nickname, file->filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float display_size = twc_tfer_cut_size(file->size);
|
float display_size = twc_tfer_cut_size(file->size);
|
||||||
const char *size_suffix = twc_tfer_size_suffix(file->size);
|
const char *size_suffix = twc_tfer_size_suffix(file->size);
|
||||||
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s %i (%.2f%s)",
|
weechat_printf_y(tfer->buffer, line, "%i) %s %s: %s %i (%.2f%s)", index,
|
||||||
index,
|
type, file->nickname, file->filename, file->size,
|
||||||
type,
|
display_size, size_suffix);
|
||||||
file->nickname,
|
|
||||||
file->filename,
|
|
||||||
file->size,
|
|
||||||
display_size,
|
|
||||||
size_suffix);
|
|
||||||
}
|
}
|
||||||
if (file->status == TWC_TFER_FILE_STATUS_IN_PROGRESS)
|
if (file->status == TWC_TFER_FILE_STATUS_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
@ -473,14 +467,14 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
|
|||||||
const char *speed_suffix = twc_tfer_speed_suffix(speed);
|
const char *speed_suffix = twc_tfer_speed_suffix(speed);
|
||||||
if (file->size == UINT64_MAX)
|
if (file->size == UINT64_MAX)
|
||||||
{
|
{
|
||||||
weechat_printf_y(tfer->buffer, line + 1, "%s%.2f%s",
|
weechat_printf_y(tfer->buffer, line + 1, "%s%.2f%s", placeholder,
|
||||||
placeholder, display_speed, speed_suffix);
|
display_speed, speed_suffix);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double ratio = (double)(file->position)/(double)(file->size);
|
double ratio = (double)(file->position) / (double)(file->size);
|
||||||
int percents = (int)(ratio * 100);
|
int percents = (int)(ratio * 100);
|
||||||
|
|
||||||
char progress_bar[PROGRESS_BAR_LEN+1];
|
char progress_bar[PROGRESS_BAR_LEN + 1];
|
||||||
memset(progress_bar, ' ', PROGRESS_BAR_LEN);
|
memset(progress_bar, ' ', PROGRESS_BAR_LEN);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < PROGRESS_BAR_LEN * ratio; i++)
|
for (i = 0; i < PROGRESS_BAR_LEN * ratio; i++)
|
||||||
@ -493,31 +487,28 @@ twc_tfer_file_update(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
|
|||||||
const char *pos_suffix = twc_tfer_size_suffix(file->position);
|
const char *pos_suffix = twc_tfer_size_suffix(file->position);
|
||||||
|
|
||||||
weechat_printf_y(tfer->buffer, line + 1, "%s%i%% [%s] %.2f%s %.2f%s",
|
weechat_printf_y(tfer->buffer, line + 1, "%s%i%% [%s] %.2f%s %.2f%s",
|
||||||
placeholder,
|
placeholder, percents, progress_bar, display_pos,
|
||||||
percents,
|
pos_suffix, display_speed, speed_suffix);
|
||||||
progress_bar,
|
|
||||||
display_pos,
|
|
||||||
pos_suffix,
|
|
||||||
display_speed,
|
|
||||||
speed_suffix);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
weechat_printf_y(tfer->buffer, line + 1, "%s%s",
|
weechat_printf_y(tfer->buffer, line + 1, "%s%s", placeholder, status);
|
||||||
placeholder,status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate and return "uint8_t data[length]" chunk of data starting from "position".
|
* Allocate and return "uint8_t data[length]" chunk of data starting from
|
||||||
|
* "position".
|
||||||
*/
|
*/
|
||||||
uint8_t *
|
uint8_t *
|
||||||
twc_tfer_file_get_chunk(struct t_twc_tfer_file *file, uint64_t position, size_t length)
|
twc_tfer_file_get_chunk(struct t_twc_tfer_file *file, uint64_t position,
|
||||||
|
size_t length)
|
||||||
{
|
{
|
||||||
fseek(file->fp, position, SEEK_SET);
|
fseek(file->fp, position, SEEK_SET);
|
||||||
uint8_t *data = malloc(sizeof(uint8_t) * length);
|
uint8_t *data = malloc(sizeof(uint8_t) * length);
|
||||||
size_t read = fread(data, sizeof(uint8_t), length, file->fp);
|
size_t read = fread(data, sizeof(uint8_t), length, file->fp);
|
||||||
while ((read < length) && !feof(file->fp))
|
while ((read < length) && !feof(file->fp))
|
||||||
{
|
{
|
||||||
read += fread(data + read * sizeof(uint8_t), sizeof(uint8_t), length - read, file->fp);
|
read += fread(data + read * sizeof(uint8_t), sizeof(uint8_t),
|
||||||
|
length - read, file->fp);
|
||||||
}
|
}
|
||||||
if (read != length)
|
if (read != length)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -528,13 +519,15 @@ twc_tfer_file_get_chunk(struct t_twc_tfer_file *file, uint64_t position, size_t
|
|||||||
* Write a chunk to the file.
|
* Write a chunk to the file.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
twc_tfer_file_write_chunk(struct t_twc_tfer_file *file, const uint8_t *data, uint64_t position, size_t length)
|
twc_tfer_file_write_chunk(struct t_twc_tfer_file *file, const uint8_t *data,
|
||||||
|
uint64_t position, size_t length)
|
||||||
{
|
{
|
||||||
fseek(file->fp, position, SEEK_SET);
|
fseek(file->fp, position, SEEK_SET);
|
||||||
size_t wrote = fwrite(data, sizeof(uint8_t), length, file->fp);
|
size_t wrote = fwrite(data, sizeof(uint8_t), length, file->fp);
|
||||||
while (wrote < length)
|
while (wrote < length)
|
||||||
{
|
{
|
||||||
wrote += fwrite(data + wrote * sizeof(uint8_t), sizeof(uint8_t), length - wrote, file->fp);
|
wrote += fwrite(data + wrote * sizeof(uint8_t), sizeof(uint8_t),
|
||||||
|
length - wrote, file->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wrote != length)
|
if (wrote != length)
|
||||||
@ -550,7 +543,7 @@ twc_tfer_file_get_by_number(struct t_twc_tfer *tfer, uint32_t file_number)
|
|||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
twc_list_foreach(tfer->files, index, item)
|
twc_list_foreach (tfer->files, index, item)
|
||||||
{
|
{
|
||||||
if (item->file->file_number == file_number)
|
if (item->file->file_number == file_number)
|
||||||
return item->file;
|
return item->file;
|
||||||
@ -566,7 +559,7 @@ twc_tfer_file_get_index(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file)
|
|||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
twc_list_foreach(tfer->files, index, item)
|
twc_list_foreach (tfer->files, index, item)
|
||||||
{
|
{
|
||||||
if (item->file == file)
|
if (item->file == file)
|
||||||
return index;
|
return index;
|
||||||
@ -593,7 +586,7 @@ twc_tfer_buffer_update(struct t_twc_tfer *tfer)
|
|||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
twc_list_foreach(tfer->files, index, item)
|
twc_list_foreach (tfer->files, index, item)
|
||||||
{
|
{
|
||||||
twc_tfer_file_update(tfer, item->file);
|
twc_tfer_file_update(tfer, item->file);
|
||||||
}
|
}
|
||||||
@ -608,11 +601,11 @@ twc_tfer_buffer_refresh(struct t_twc_tfer *tfer)
|
|||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
twc_list_foreach(tfer->files, index, item)
|
twc_list_foreach (tfer->files, index, item)
|
||||||
{
|
{
|
||||||
enum t_twc_tfer_file_status status = item->file->status;
|
enum t_twc_tfer_file_status status = item->file->status;
|
||||||
if (status == TWC_TFER_FILE_STATUS_DECLINED ||
|
if (status == TWC_TFER_FILE_STATUS_DECLINED ||
|
||||||
status == TWC_TFER_FILE_STATUS_ABORTED ||
|
status == TWC_TFER_FILE_STATUS_ABORTED ||
|
||||||
status == TWC_TFER_FILE_STATUS_DONE)
|
status == TWC_TFER_FILE_STATUS_DONE)
|
||||||
{
|
{
|
||||||
struct t_twc_tfer_file *file = twc_list_remove(item);
|
struct t_twc_tfer_file *file = twc_list_remove(item);
|
||||||
@ -626,9 +619,9 @@ twc_tfer_buffer_refresh(struct t_twc_tfer *tfer)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send TOX_FILE_CONTROL command to a client.
|
* Send TOX_FILE_CONTROL command to a client.
|
||||||
* "сheck" is a file status that a file should be in before sending a control command.
|
* "сheck" is a file status that a file should be in before sending a control
|
||||||
* "send" is a control comand you are going to send.
|
* command. "send" is a control comand you are going to send. "set" is a file
|
||||||
* "set" is a file status that will be set after successful sending a control command.
|
* status that will be set after successful sending a control command.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
||||||
@ -649,8 +642,10 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
|||||||
&control_error);
|
&control_error);
|
||||||
if (control_error)
|
if (control_error)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%scannot send control command for \"%s\" file: %s",
|
weechat_printf(profile->buffer,
|
||||||
weechat_prefix("error"), file->filename, twc_tox_err_file_control(control_error));
|
"%scannot send control command for \"%s\" file: %s",
|
||||||
|
weechat_prefix("error"), file->filename,
|
||||||
|
twc_tox_err_file_control(control_error));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -658,7 +653,8 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
|||||||
if (send == TOX_FILE_CONTROL_CANCEL)
|
if (send == TOX_FILE_CONTROL_CANCEL)
|
||||||
{
|
{
|
||||||
fclose(file->fp);
|
fclose(file->fp);
|
||||||
if (file->type == TWC_TFER_FILE_TYPE_DOWNLOADING && file->size != UINT64_MAX)
|
if (file->type == TWC_TFER_FILE_TYPE_DOWNLOADING &&
|
||||||
|
file->size != UINT64_MAX)
|
||||||
remove(file->full_path);
|
remove(file->full_path);
|
||||||
}
|
}
|
||||||
file->status = set;
|
file->status = set;
|
||||||
@ -667,8 +663,6 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept a file with number <index> in the list.
|
* Accept a file with number <index> in the list.
|
||||||
* Returns 1 if successful, 0 when there's an issue with tox calls
|
* Returns 1 if successful, 0 when there's an issue with tox calls
|
||||||
@ -677,10 +671,9 @@ twc_tfer_file_send_control(struct t_twc_profile *profile, size_t index,
|
|||||||
int
|
int
|
||||||
twc_tfer_file_accept(struct t_twc_profile *profile, size_t index)
|
twc_tfer_file_accept(struct t_twc_profile *profile, size_t index)
|
||||||
{
|
{
|
||||||
return twc_tfer_file_send_control(profile, index,
|
return twc_tfer_file_send_control(
|
||||||
TWC_TFER_FILE_STATUS_REQUEST,
|
profile, index, TWC_TFER_FILE_STATUS_REQUEST, TOX_FILE_CONTROL_RESUME,
|
||||||
TOX_FILE_CONTROL_RESUME,
|
TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
||||||
TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -691,10 +684,9 @@ twc_tfer_file_accept(struct t_twc_profile *profile, size_t index)
|
|||||||
int
|
int
|
||||||
twc_tfer_file_decline(struct t_twc_profile *profile, size_t index)
|
twc_tfer_file_decline(struct t_twc_profile *profile, size_t index)
|
||||||
{
|
{
|
||||||
return twc_tfer_file_send_control(profile, index,
|
return twc_tfer_file_send_control(
|
||||||
TWC_TFER_FILE_STATUS_REQUEST,
|
profile, index, TWC_TFER_FILE_STATUS_REQUEST, TOX_FILE_CONTROL_CANCEL,
|
||||||
TOX_FILE_CONTROL_CANCEL,
|
TWC_TFER_FILE_STATUS_DECLINED);
|
||||||
TWC_TFER_FILE_STATUS_DECLINED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -705,10 +697,9 @@ twc_tfer_file_decline(struct t_twc_profile *profile, size_t index)
|
|||||||
int
|
int
|
||||||
twc_tfer_file_pause(struct t_twc_profile *profile, size_t index)
|
twc_tfer_file_pause(struct t_twc_profile *profile, size_t index)
|
||||||
{
|
{
|
||||||
return twc_tfer_file_send_control(profile, index,
|
return twc_tfer_file_send_control(
|
||||||
TWC_TFER_FILE_STATUS_IN_PROGRESS,
|
profile, index, TWC_TFER_FILE_STATUS_IN_PROGRESS,
|
||||||
TOX_FILE_CONTROL_PAUSE,
|
TOX_FILE_CONTROL_PAUSE, TWC_TFER_FILE_STATUS_PAUSED);
|
||||||
TWC_TFER_FILE_STATUS_PAUSED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -719,10 +710,9 @@ twc_tfer_file_pause(struct t_twc_profile *profile, size_t index)
|
|||||||
int
|
int
|
||||||
twc_tfer_file_continue(struct t_twc_profile *profile, size_t index)
|
twc_tfer_file_continue(struct t_twc_profile *profile, size_t index)
|
||||||
{
|
{
|
||||||
return twc_tfer_file_send_control(profile, index,
|
return twc_tfer_file_send_control(
|
||||||
TWC_TFER_FILE_STATUS_PAUSED,
|
profile, index, TWC_TFER_FILE_STATUS_PAUSED, TOX_FILE_CONTROL_RESUME,
|
||||||
TOX_FILE_CONTROL_RESUME,
|
TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
||||||
TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -733,10 +723,9 @@ twc_tfer_file_continue(struct t_twc_profile *profile, size_t index)
|
|||||||
int
|
int
|
||||||
twc_tfer_file_abort(struct t_twc_profile *profile, size_t index)
|
twc_tfer_file_abort(struct t_twc_profile *profile, size_t index)
|
||||||
{
|
{
|
||||||
return twc_tfer_file_send_control(profile, index,
|
return twc_tfer_file_send_control(
|
||||||
TWC_TFER_FILE_STATUS_IN_PROGRESS,
|
profile, index, TWC_TFER_FILE_STATUS_IN_PROGRESS,
|
||||||
TOX_FILE_CONTROL_CANCEL,
|
TOX_FILE_CONTROL_CANCEL, TWC_TFER_FILE_STATUS_ABORTED);
|
||||||
TWC_TFER_FILE_STATUS_ABORTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -751,9 +740,13 @@ twc_tfer_buffer_input_callback(const void *pointer, void *data,
|
|||||||
profile = (struct t_twc_profile *)pointer;
|
profile = (struct t_twc_profile *)pointer;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv = weechat_string_split_shell(input_data, &argc);
|
char **argv = weechat_string_split_shell(input_data, &argc);
|
||||||
char *status = malloc(sizeof(char) * weechat_window_get_integer(weechat_current_window(), "win_width") + 1);
|
char *status =
|
||||||
|
malloc(sizeof(char) * weechat_window_get_integer(
|
||||||
|
weechat_current_window(), "win_width") +
|
||||||
|
1);
|
||||||
|
|
||||||
/* refresh file list, i.e delete files that have been marked as "denied", "aborted" and "done" */
|
/* refresh file list, i.e delete files that have been marked as "denied",
|
||||||
|
* "aborted" and "done" */
|
||||||
if (weechat_strcasecmp(argv[0], "r") == 0)
|
if (weechat_strcasecmp(argv[0], "r") == 0)
|
||||||
{
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
@ -763,7 +756,8 @@ twc_tfer_buffer_input_callback(const void *pointer, void *data,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TWC_TFER_UPDATE_STATUS_AND_RETURN("this command doesn't accept any arguments");
|
TWC_TFER_UPDATE_STATUS_AND_RETURN(
|
||||||
|
"this command doesn't accept any arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strstr("adpcbADPCB", argv[0]) && argc < 2)
|
if (strstr("adpcbADPCB", argv[0]) && argc < 2)
|
||||||
@ -771,14 +765,16 @@ twc_tfer_buffer_input_callback(const void *pointer, void *data,
|
|||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
size_t n = (size_t)strtol(argv[1], NULL, 0);
|
size_t n = (size_t)strtol(argv[1], NULL, 0);
|
||||||
if ((n == 0 && strcmp(argv[1], "0") != 0) || n > (profile->tfer->files->count - 1))
|
if ((n == 0 && strcmp(argv[1], "0") != 0) ||
|
||||||
|
n > (profile->tfer->files->count - 1))
|
||||||
{
|
{
|
||||||
TWC_TFER_UPDATE_STATUS_AND_RETURN("<n> must be existing number of file");
|
TWC_TFER_UPDATE_STATUS_AND_RETURN(
|
||||||
|
"<n> must be existing number of file");
|
||||||
}
|
}
|
||||||
/* accept */
|
/* accept */
|
||||||
if (weechat_strcasecmp(argv[0], "a") == 0)
|
if (weechat_strcasecmp(argv[0], "a") == 0)
|
||||||
{
|
{
|
||||||
TWC_TFER_MESSAGE(accept, accepted);
|
TWC_TFER_MESSAGE(accept, accepted);
|
||||||
}
|
}
|
||||||
/* decline */
|
/* decline */
|
||||||
if (weechat_strcasecmp(argv[0], "d") == 0)
|
if (weechat_strcasecmp(argv[0], "d") == 0)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of Tox-WeeChat.
|
* This file is part of Tox-WeeChat.
|
||||||
*
|
*
|
||||||
* Tox-WeeChat is free software: you can redistribute it and/or modify
|
* Tox-WeeChat is free software: you can redistribute it and/or modify
|
||||||
@ -47,14 +47,14 @@ enum t_twc_tfer_file_status
|
|||||||
enum t_twc_tfer_file_type
|
enum t_twc_tfer_file_type
|
||||||
{
|
{
|
||||||
TWC_TFER_FILE_TYPE_DOWNLOADING,
|
TWC_TFER_FILE_TYPE_DOWNLOADING,
|
||||||
TWC_TFER_FILE_TYPE_UPLOADING,
|
TWC_TFER_FILE_TYPE_UPLOADING,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct t_twc_tfer_file
|
struct t_twc_tfer_file
|
||||||
{
|
{
|
||||||
enum t_twc_tfer_file_status status;
|
enum t_twc_tfer_file_status status;
|
||||||
enum t_twc_tfer_file_type type;
|
enum t_twc_tfer_file_type type;
|
||||||
uint64_t position; /* already transmitted (in bytes) */
|
uint64_t position; /* already transmitted (in bytes) */
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
uint32_t friend_number;
|
uint32_t friend_number;
|
||||||
uint32_t file_number;
|
uint32_t file_number;
|
||||||
@ -103,19 +103,21 @@ char *
|
|||||||
twc_tfer_file_name_strip(const char *original, size_t size);
|
twc_tfer_file_name_strip(const char *original, size_t size);
|
||||||
|
|
||||||
struct t_twc_tfer_file *
|
struct t_twc_tfer_file *
|
||||||
twc_tfer_file_new(struct t_twc_profile *profile,
|
twc_tfer_file_new(struct t_twc_profile *profile, const char *nickname,
|
||||||
const char *nickname, const char *filename,
|
const char *filename, uint32_t friend_number,
|
||||||
uint32_t friend_number, uint32_t file_number,
|
uint32_t file_number, uint64_t size,
|
||||||
uint64_t size, enum t_twc_tfer_file_type filetype);
|
enum t_twc_tfer_file_type filetype);
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_tfer_file_add(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file);
|
twc_tfer_file_add(struct t_twc_tfer *tfer, struct t_twc_tfer_file *file);
|
||||||
|
|
||||||
uint8_t *
|
uint8_t *
|
||||||
twc_tfer_file_get_chunk(struct t_twc_tfer_file *file, uint64_t position, size_t length);
|
twc_tfer_file_get_chunk(struct t_twc_tfer_file *file, uint64_t position,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
twc_tfer_file_write_chunk(struct t_twc_tfer_file *file, const uint8_t *data, uint64_t position, size_t length);
|
twc_tfer_file_write_chunk(struct t_twc_tfer_file *file, const uint8_t *data,
|
||||||
|
uint64_t position, size_t length);
|
||||||
|
|
||||||
struct t_twc_tfer_file *
|
struct t_twc_tfer_file *
|
||||||
twc_tfer_file_get_by_number(struct t_twc_tfer *tfer, uint32_t file_number);
|
twc_tfer_file_get_by_number(struct t_twc_tfer *tfer, uint32_t file_number);
|
||||||
|
@ -32,13 +32,15 @@
|
|||||||
#include "twc-group-invite.h"
|
#include "twc-group-invite.h"
|
||||||
#include "twc-message-queue.h"
|
#include "twc-message-queue.h"
|
||||||
#include "twc-profile.h"
|
#include "twc-profile.h"
|
||||||
#include "twc-utils.h"
|
|
||||||
#include "twc-tfer.h"
|
#include "twc-tfer.h"
|
||||||
|
#include "twc-utils.h"
|
||||||
#include "twc.h"
|
#include "twc.h"
|
||||||
|
|
||||||
#include "twc-tox-callbacks.h"
|
#include "twc-tox-callbacks.h"
|
||||||
|
|
||||||
#define TWC_TFER_FILE_UPDATE_STATUS(st) do { \
|
#define TWC_TFER_FILE_UPDATE_STATUS(st) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
file->status = st; \
|
file->status = st; \
|
||||||
twc_tfer_file_update(profile->tfer, file); \
|
twc_tfer_file_update(profile->tfer, file); \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -57,8 +59,7 @@ twc_do_timer_cb(const void *pointer, void *data, int remaining_calls)
|
|||||||
interval = tox_iteration_interval(profile->tox);
|
interval = tox_iteration_interval(profile->tox);
|
||||||
tox_iterate(profile->tox, profile);
|
tox_iterate(profile->tox, profile);
|
||||||
struct t_hook *hook =
|
struct t_hook *hook =
|
||||||
weechat_hook_timer(interval, 0, 1,
|
weechat_hook_timer(interval, 0, 1, twc_do_timer_cb, profile, NULL);
|
||||||
twc_do_timer_cb, profile, NULL);
|
|
||||||
profile->tox_do_timer = hook;
|
profile->tox_do_timer = hook;
|
||||||
|
|
||||||
/* check connection status */
|
/* check connection status */
|
||||||
@ -70,24 +71,26 @@ twc_do_timer_cb(const void *pointer, void *data, int remaining_calls)
|
|||||||
if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN))
|
if (TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_AUTOJOIN))
|
||||||
{
|
{
|
||||||
struct t_twc_group_chat_invite *invite;
|
struct t_twc_group_chat_invite *invite;
|
||||||
for(i = 0; (invite = twc_group_chat_invite_with_index(profile, i)); i++)
|
for (i = 0; (invite = twc_group_chat_invite_with_index(profile, i));
|
||||||
if(invite->autojoin_delay <= 0)
|
i++)
|
||||||
|
if (invite->autojoin_delay <= 0)
|
||||||
{
|
{
|
||||||
struct t_twc_chat *friend_chat =
|
struct t_twc_chat *friend_chat = twc_chat_search_friend(
|
||||||
twc_chat_search_friend(profile, invite->friend_number, false);
|
profile, invite->friend_number, false);
|
||||||
char *friend_name = twc_get_name_nt(profile->tox, invite->friend_number);
|
char *friend_name =
|
||||||
|
twc_get_name_nt(profile->tox, invite->friend_number);
|
||||||
char *type_str;
|
char *type_str;
|
||||||
switch (invite->group_chat_type)
|
switch (invite->group_chat_type)
|
||||||
{
|
{
|
||||||
case TOX_CONFERENCE_TYPE_TEXT:
|
case TOX_CONFERENCE_TYPE_TEXT:
|
||||||
type_str = "a text-only group chat";
|
type_str = "a text-only group chat";
|
||||||
break;
|
break;
|
||||||
case TOX_CONFERENCE_TYPE_AV:
|
case TOX_CONFERENCE_TYPE_AV:
|
||||||
type_str = "an audio/vikdeo group chat";
|
type_str = "an audio/vikdeo group chat";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
type_str = "a group chat";
|
type_str = "a group chat";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = twc_group_chat_invite_join(invite);
|
rc = twc_group_chat_invite_join(invite);
|
||||||
@ -99,17 +102,19 @@ twc_do_timer_cb(const void *pointer, void *data, int remaining_calls)
|
|||||||
if (friend_chat)
|
if (friend_chat)
|
||||||
{
|
{
|
||||||
weechat_printf_date_tags(
|
weechat_printf_date_tags(
|
||||||
friend_chat->buffer, 0, tags,
|
friend_chat->buffer, 0, tags,
|
||||||
"%sWe joined the %s%s%s's invite to %s.",
|
"%sWe joined the %s%s%s's invite to %s.",
|
||||||
weechat_prefix("network"), weechat_color("chat_nick_other"),
|
weechat_prefix("network"),
|
||||||
friend_name, weechat_color("reset"), type_str);
|
weechat_color("chat_nick_other"), friend_name,
|
||||||
|
weechat_color("reset"), type_str);
|
||||||
tags = "";
|
tags = "";
|
||||||
}
|
}
|
||||||
weechat_printf_date_tags(
|
weechat_printf_date_tags(
|
||||||
profile->buffer, 0, tags,
|
profile->buffer, 0, tags,
|
||||||
"%sWe joined the %s%s%s's invite to %s.",
|
"%sWe joined the %s%s%s's invite to %s.",
|
||||||
weechat_prefix("network"), weechat_color("chat_nick_other"),
|
weechat_prefix("network"),
|
||||||
friend_name, weechat_color("reset"), type_str);
|
weechat_color("chat_nick_other"), friend_name,
|
||||||
|
weechat_color("reset"), type_str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -117,19 +122,21 @@ twc_do_timer_cb(const void *pointer, void *data, int remaining_calls)
|
|||||||
if (friend_chat)
|
if (friend_chat)
|
||||||
{
|
{
|
||||||
weechat_printf_date_tags(
|
weechat_printf_date_tags(
|
||||||
friend_chat->buffer, 0, tags,
|
friend_chat->buffer, 0, tags,
|
||||||
"%s%s%s%s invites you to join %s, but we failed to "
|
"%s%s%s%s invites you to join %s, but we failed to "
|
||||||
"process the invite. Please try again.",
|
"process the invite. Please try again.",
|
||||||
weechat_prefix("network"), weechat_color("chat_nick_other"),
|
weechat_prefix("network"),
|
||||||
friend_name, weechat_color("reset"));
|
weechat_color("chat_nick_other"), friend_name,
|
||||||
|
weechat_color("reset"));
|
||||||
tags = "";
|
tags = "";
|
||||||
}
|
}
|
||||||
weechat_printf_date_tags(
|
weechat_printf_date_tags(
|
||||||
profile->buffer, 0, tags,
|
profile->buffer, 0, tags,
|
||||||
"%s%s%s%s invites you to join %s, but we failed to "
|
"%s%s%s%s invites you to join %s, but we failed to "
|
||||||
"process the invite. Please try again.",
|
"process the invite. Please try again.",
|
||||||
weechat_prefix("network"), weechat_color("chat_nick_other"),
|
weechat_prefix("network"),
|
||||||
friend_name, weechat_color("reset"));
|
weechat_color("chat_nick_other"), friend_name,
|
||||||
|
weechat_color("reset"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -239,7 +246,7 @@ twc_name_change_callback(Tox *tox, uint32_t friend_number, const uint8_t *name,
|
|||||||
size_t index;
|
size_t index;
|
||||||
struct t_twc_list_item *item;
|
struct t_twc_list_item *item;
|
||||||
struct t_twc_tfer_file *file;
|
struct t_twc_tfer_file *file;
|
||||||
twc_list_foreach(profile->tfer->files, index, item)
|
twc_list_foreach (profile->tfer->files, index, item)
|
||||||
{
|
{
|
||||||
file = item->file;
|
file = item->file;
|
||||||
if (file->friend_number == friend_number)
|
if (file->friend_number == friend_number)
|
||||||
@ -361,12 +368,12 @@ twc_group_invite_callback(Tox *tox, uint32_t friend_number,
|
|||||||
friend_name, weechat_color("reset"), type_str, rc);
|
friend_name, weechat_color("reset"), type_str, rc);
|
||||||
tags = "";
|
tags = "";
|
||||||
}
|
}
|
||||||
weechat_printf_date_tags(
|
weechat_printf_date_tags(profile->buffer, 0, tags,
|
||||||
profile->buffer, 0, tags,
|
"%s%s%s%s invites you to join %s. Type "
|
||||||
"%s%s%s%s invites you to join %s. Type "
|
"\"/group join %d\" to accept.",
|
||||||
"\"/group join %d\" to accept.",
|
weechat_prefix("network"),
|
||||||
weechat_prefix("network"), weechat_color("chat_nick_other"),
|
weechat_color("chat_nick_other"), friend_name,
|
||||||
friend_name, weechat_color("reset"), type_str, rc);
|
weechat_color("reset"), type_str, rc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -505,10 +512,8 @@ twc_group_peer_list_changed_callback(Tox *tox, uint32_t group_number,
|
|||||||
|
|
||||||
void
|
void
|
||||||
twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
|
twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number, const uint8_t *pname,
|
||||||
const uint8_t *pname,
|
size_t pname_len, void *data)
|
||||||
size_t pname_len,
|
|
||||||
void *data)
|
|
||||||
{
|
{
|
||||||
struct t_twc_profile *profile = data;
|
struct t_twc_profile *profile = data;
|
||||||
struct t_twc_chat *chat =
|
struct t_twc_chat *chat =
|
||||||
@ -549,26 +554,26 @@ twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
|
|||||||
prev_name = weechat_list_string(n);
|
prev_name = weechat_list_string(n);
|
||||||
name = twc_null_terminate(pname, pname_len);
|
name = twc_null_terminate(pname, pname_len);
|
||||||
|
|
||||||
nick = weechat_nicklist_search_nick(chat->buffer,
|
nick = weechat_nicklist_search_nick(chat->buffer, chat->nicklist_group,
|
||||||
chat->nicklist_group, prev_name);
|
prev_name);
|
||||||
|
|
||||||
weechat_nicklist_remove_nick(chat->buffer, nick);
|
weechat_nicklist_remove_nick(chat->buffer, nick);
|
||||||
|
|
||||||
err = TOX_ERR_CONFERENCE_PEER_QUERY_OK;
|
err = TOX_ERR_CONFERENCE_PEER_QUERY_OK;
|
||||||
rc = tox_conference_peer_number_is_ours(tox, group_number, peer_number, &err);
|
rc = tox_conference_peer_number_is_ours(tox, group_number, peer_number,
|
||||||
|
&err);
|
||||||
if ((err == TOX_ERR_CONFERENCE_PEER_QUERY_OK) && (!rc))
|
if ((err == TOX_ERR_CONFERENCE_PEER_QUERY_OK) && (!rc))
|
||||||
weechat_printf(chat->buffer, "%s%s is now known as %s",
|
weechat_printf(chat->buffer, "%s%s is now known as %s",
|
||||||
weechat_prefix("network"), prev_name, name);
|
weechat_prefix("network"), prev_name, name);
|
||||||
|
|
||||||
weechat_list_set(n, name);
|
weechat_list_set(n, name);
|
||||||
|
|
||||||
weechat_nicklist_add_nick(chat->buffer, chat->nicklist_group, name,
|
weechat_nicklist_add_nick(chat->buffer, chat->nicklist_group, name, NULL,
|
||||||
NULL, NULL, NULL, 1);
|
NULL, NULL, 1);
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
|
twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
|
||||||
const uint8_t *title, size_t length, void *data)
|
const uint8_t *title, size_t length, void *data)
|
||||||
@ -587,55 +592,62 @@ twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_control_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
twc_file_recv_control_callback(Tox *tox, uint32_t friend_number,
|
||||||
TOX_FILE_CONTROL control, void *user_data)
|
uint32_t file_number, TOX_FILE_CONTROL control,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
||||||
struct t_twc_tfer_file *file = twc_tfer_file_get_by_number(profile->tfer, file_number);
|
struct t_twc_tfer_file *file =
|
||||||
|
twc_tfer_file_get_by_number(profile->tfer, file_number);
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->tfer->buffer, "%sthere is no file with number %i in queue",
|
weechat_printf(profile->tfer->buffer,
|
||||||
|
"%sthere is no file with number %i in queue",
|
||||||
weechat_prefix("error"), file_number);
|
weechat_prefix("error"), file_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (control)
|
switch (control)
|
||||||
{
|
{
|
||||||
case TOX_FILE_CONTROL_RESUME:
|
case TOX_FILE_CONTROL_RESUME:
|
||||||
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
case TOX_FILE_CONTROL_PAUSE:
|
case TOX_FILE_CONTROL_PAUSE:
|
||||||
if (file->position !=0)
|
if (file->position != 0)
|
||||||
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_PAUSED);
|
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_PAUSED);
|
||||||
break;
|
break;
|
||||||
case TOX_FILE_CONTROL_CANCEL:
|
case TOX_FILE_CONTROL_CANCEL:
|
||||||
fclose(file->fp);
|
fclose(file->fp);
|
||||||
if (file->type == TWC_TFER_FILE_TYPE_DOWNLOADING && file->size != UINT64_MAX)
|
if (file->type == TWC_TFER_FILE_TYPE_DOWNLOADING &&
|
||||||
remove(file->full_path);
|
file->size != UINT64_MAX)
|
||||||
if (file->position != 0)
|
remove(file->full_path);
|
||||||
{
|
if (file->position != 0)
|
||||||
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_ABORTED);
|
{
|
||||||
}
|
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_ABORTED);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_DECLINED);
|
{
|
||||||
}
|
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_DECLINED);
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number,
|
||||||
uint64_t position, size_t length, void *user_data)
|
uint32_t file_number, uint64_t position,
|
||||||
|
size_t length, void *user_data)
|
||||||
{
|
{
|
||||||
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
||||||
struct t_twc_tfer_file *file = twc_tfer_file_get_by_number(profile->tfer, file_number);
|
struct t_twc_tfer_file *file =
|
||||||
|
twc_tfer_file_get_by_number(profile->tfer, file_number);
|
||||||
/* the file is missing */
|
/* the file is missing */
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->tfer->buffer, "%sthere is no file with number %i in queue",
|
weechat_printf(profile->tfer->buffer,
|
||||||
|
"%sthere is no file with number %i in queue",
|
||||||
weechat_prefix("error"), file_number);
|
weechat_prefix("error"), file_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* 0-length chunk requested that means the file transmission is completed */
|
/* 0-length chunk requested that means the file transmission is completed */
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
@ -657,10 +669,12 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number, uint32_t file_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
enum TOX_ERR_FILE_SEND_CHUNK error;
|
enum TOX_ERR_FILE_SEND_CHUNK error;
|
||||||
tox_file_send_chunk(profile->tox, friend_number, file_number, position, data, length, &error);
|
tox_file_send_chunk(profile->tox, friend_number, file_number, position,
|
||||||
|
data, length, &error);
|
||||||
if (error)
|
if (error)
|
||||||
weechat_printf(profile->buffer, "%s%s: chunk sending error: %s",
|
weechat_printf(profile->buffer, "%s%s: chunk sending error: %s",
|
||||||
weechat_prefix("error"), file->filename, twc_tox_err_file_send_chunk(error));
|
weechat_prefix("error"), file->filename,
|
||||||
|
twc_tox_err_file_send_chunk(error));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file->position += length;
|
file->position += length;
|
||||||
@ -677,14 +691,16 @@ twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number, uint32_t file_
|
|||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
||||||
uint32_t kind, uint64_t file_size, const uint8_t *filename,
|
uint32_t kind, uint64_t file_size,
|
||||||
size_t filename_length, void *user_data)
|
const uint8_t *filename, size_t filename_length,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
||||||
if (kind == TOX_FILE_KIND_AVATAR)
|
if (kind == TOX_FILE_KIND_AVATAR)
|
||||||
{
|
{
|
||||||
TOX_ERR_FILE_CONTROL error;
|
TOX_ERR_FILE_CONTROL error;
|
||||||
tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_CANCEL, &error);
|
tox_file_control(tox, friend_number, file_number,
|
||||||
|
TOX_FILE_CONTROL_CANCEL, &error);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%scannot cancel avatar receiving",
|
weechat_printf(profile->buffer, "%scannot cancel avatar receiving",
|
||||||
@ -694,14 +710,15 @@ twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
|||||||
}
|
}
|
||||||
char *name = twc_get_name_nt(tox, friend_number);
|
char *name = twc_get_name_nt(tox, friend_number);
|
||||||
char *fname = twc_null_terminate(filename, filename_length);
|
char *fname = twc_null_terminate(filename, filename_length);
|
||||||
struct t_twc_tfer_file *file = twc_tfer_file_new(profile, name, fname,
|
struct t_twc_tfer_file *file =
|
||||||
friend_number, file_number,
|
twc_tfer_file_new(profile, name, fname, friend_number, file_number,
|
||||||
file_size, TWC_TFER_FILE_TYPE_DOWNLOADING);
|
file_size, TWC_TFER_FILE_TYPE_DOWNLOADING);
|
||||||
free(name);
|
free(name);
|
||||||
free(fname);
|
free(fname);
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->buffer, "%scannot open the file \"%s\" with write permissions",
|
weechat_printf(profile->buffer,
|
||||||
|
"%scannot open the file \"%s\" with write permissions",
|
||||||
weechat_prefix("error"), filename);
|
weechat_prefix("error"), filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -715,19 +732,24 @@ twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number,
|
||||||
const uint8_t *data, size_t length, void *user_data)
|
uint32_t file_number, uint64_t position,
|
||||||
|
const uint8_t *data, size_t length,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
struct t_twc_profile *profile = twc_profile_search_tox(tox);
|
||||||
struct t_twc_tfer_file *file = twc_tfer_file_get_by_number(profile->tfer, file_number);
|
struct t_twc_tfer_file *file =
|
||||||
|
twc_tfer_file_get_by_number(profile->tfer, file_number);
|
||||||
/* the file is missing */
|
/* the file is missing */
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
weechat_printf(profile->tfer->buffer, "%sthere is no file with number %i in queue",
|
weechat_printf(profile->tfer->buffer,
|
||||||
|
"%sthere is no file with number %i in queue",
|
||||||
weechat_prefix("error"), file_number);
|
weechat_prefix("error"), file_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* 0-length chunk transmitted that means the file transmission is completed */
|
/* 0-length chunk transmitted that means the file transmission is completed
|
||||||
|
*/
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_DONE);
|
TWC_TFER_FILE_UPDATE_STATUS(TWC_TFER_FILE_STATUS_DONE);
|
||||||
|
@ -66,30 +66,34 @@ twc_group_peer_list_changed_callback(Tox *tox, uint32_t group_number,
|
|||||||
|
|
||||||
void
|
void
|
||||||
twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
|
twc_group_peer_name_callback(Tox *tox, uint32_t group_number,
|
||||||
uint32_t peer_number,
|
uint32_t peer_number, const uint8_t *nick,
|
||||||
const uint8_t *nick,
|
size_t nick_len, void *data);
|
||||||
size_t nick_len,
|
|
||||||
void *data);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
|
twc_group_title_callback(Tox *tox, uint32_t group_number, uint32_t peer_number,
|
||||||
const uint8_t *title, size_t length, void *data);
|
const uint8_t *title, size_t length, void *data);
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_control_callback(Tox *tox, uint32_t friend_number, uint32_t file_number, TOX_FILE_CONTROL control,
|
twc_file_recv_control_callback(Tox *tox, uint32_t friend_number,
|
||||||
void *user_data);
|
uint32_t file_number, TOX_FILE_CONTROL control,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
twc_file_chunk_request_callback(Tox *tox, uint32_t friend_number,
|
||||||
size_t length, void *user_data);
|
uint32_t file_number, uint64_t position,
|
||||||
|
size_t length, void *user_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t file_size,
|
twc_file_recv_callback(Tox *tox, uint32_t friend_number, uint32_t file_number,
|
||||||
const uint8_t *filename, size_t filename_length, void *user_data);
|
uint32_t kind, uint64_t file_size,
|
||||||
|
const uint8_t *filename, size_t filename_length,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
twc_file_recv_chunk_callback(Tox *tox, uint32_t friend_number,
|
||||||
const uint8_t *data, size_t length, void *user_data);
|
uint32_t file_number, uint64_t position,
|
||||||
|
const uint8_t *data, size_t length,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
void
|
void
|
||||||
|
@ -245,12 +245,13 @@ twc_tox_err_file_control(enum TOX_ERR_FILE_CONTROL error)
|
|||||||
"success",
|
"success",
|
||||||
"the friend number passed did not designate a valid friend",
|
"the friend number passed did not designate a valid friend",
|
||||||
"this client is currently not connected to the friend",
|
"this client is currently not connected to the friend",
|
||||||
"no file transfer with the given file number was found for the given friend",
|
"no file transfer with the given file number was found for the given "
|
||||||
|
"friend",
|
||||||
"a RESUME control was sent, but the file transfer is running normally",
|
"a RESUME control was sent, but the file transfer is running normally",
|
||||||
"A RESUME control was sent, but the file transfer was paused by the other party",
|
"A RESUME control was sent, but the file transfer was paused by the "
|
||||||
|
"other party",
|
||||||
"a PAUSE control was sent, but the file transfer was already paused",
|
"a PAUSE control was sent, but the file transfer was already paused",
|
||||||
"packet queue is full"
|
"packet queue is full"};
|
||||||
};
|
|
||||||
return messages[error];
|
return messages[error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,10 +260,11 @@ twc_tox_err_file_get(enum TOX_ERR_FILE_GET error)
|
|||||||
{
|
{
|
||||||
char *messages[] = {
|
char *messages[] = {
|
||||||
"success",
|
"success",
|
||||||
"one of the arguments to the function was NULL when it was not expected",
|
"one of the arguments to the function was NULL when it was not "
|
||||||
|
"expected",
|
||||||
"the friend number passed did not designate a valid friend",
|
"the friend number passed did not designate a valid friend",
|
||||||
"no file transfer with the given number was found for the given friend"
|
"no file transfer with the given number was found for the given "
|
||||||
};
|
"friend"};
|
||||||
return messages[error];
|
return messages[error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,11 +275,11 @@ twc_tox_err_file_seek(enum TOX_ERR_FILE_SEEK error)
|
|||||||
"success",
|
"success",
|
||||||
"the friend number passed did not designate a valid friend",
|
"the friend number passed did not designate a valid friend",
|
||||||
"the client is currently not connected to the friend",
|
"the client is currently not connected to the friend",
|
||||||
"no file transfer with the given file number was found for the given friend",
|
"no file transfer with the given file number was found for the given "
|
||||||
|
"friend",
|
||||||
"file was not in a state where it could be seeked",
|
"file was not in a state where it could be seeked",
|
||||||
"seek position was invalid",
|
"seek position was invalid",
|
||||||
"packet queue is full"
|
"packet queue is full"};
|
||||||
};
|
|
||||||
return messages[error];
|
return messages[error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,12 +288,12 @@ twc_tox_err_file_send(enum TOX_ERR_FILE_SEND error)
|
|||||||
{
|
{
|
||||||
char *messages[] = {
|
char *messages[] = {
|
||||||
"success",
|
"success",
|
||||||
"one of the arguments of the function was NULL when it was not expected",
|
"one of the arguments of the function was NULL when it was not "
|
||||||
|
"expected",
|
||||||
"the friend number passed did not designate a valid friend",
|
"the friend number passed did not designate a valid friend",
|
||||||
"this client is currently not connected to the friend",
|
"this client is currently not connected to the friend",
|
||||||
"filename lenth exceeded TOX_MAX_FILENAME_LENGTH bytes",
|
"filename lenth exceeded TOX_MAX_FILENAME_LENGTH bytes",
|
||||||
"too many ongoing transfers"
|
"too many ongoing transfers"};
|
||||||
};
|
|
||||||
return messages[error];
|
return messages[error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,11 +305,11 @@ twc_tox_err_file_send_chunk(enum TOX_ERR_FILE_SEND_CHUNK error)
|
|||||||
"the length parameter was non-zero, but data was NULL",
|
"the length parameter was non-zero, but data was NULL",
|
||||||
"the friend number passed did not designate a valid friend",
|
"the friend number passed did not designate a valid friend",
|
||||||
"this client is currently not connected to the friend",
|
"this client is currently not connected to the friend",
|
||||||
"no file transfer with the given file number was found for the given friend",
|
"no file transfer with the given file number was found for the given "
|
||||||
|
"friend",
|
||||||
"not called from the request chunk callback",
|
"not called from the request chunk callback",
|
||||||
"attempted to send more or less data than requested",
|
"attempted to send more or less data than requested",
|
||||||
"packet queue is full",
|
"packet queue is full",
|
||||||
"position parameter was wrong"
|
"position parameter was wrong"};
|
||||||
};
|
|
||||||
return messages[error];
|
return messages[error];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user