mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 11:23:26 +01:00
don't show full path when sending files
This commit is contained in:
parent
c9e4246ac5
commit
79372cc80d
@ -373,7 +373,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec
|
||||
break;
|
||||
}
|
||||
|
||||
filename = file_senders[i].pathname;
|
||||
filename = file_senders[i].filename;
|
||||
}
|
||||
|
||||
switch (control_type) {
|
||||
|
@ -196,7 +196,8 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
|
||||
char filename[MAX_STR_SIZE] = {0};
|
||||
get_file_name(filename, sizeof(filename), path);
|
||||
int filenum = tox_new_file_sender(m, self->num, filesize, (const uint8_t *) filename, strlen(filename));
|
||||
int namelen = strlen(filename);
|
||||
int filenum = tox_new_file_sender(m, self->num, filesize, (const uint8_t *) filename, namelen);
|
||||
|
||||
if (filenum == -1) {
|
||||
errmsg = "Error sending file.";
|
||||
@ -209,7 +210,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
for (i = 0; i < MAX_FILES; ++i) {
|
||||
if (!file_senders[i].active) {
|
||||
file_senders[i].queue_pos = num_active_file_senders;
|
||||
memcpy(file_senders[i].pathname, path, path_len + 1);
|
||||
memcpy(file_senders[i].filename, filename, namelen + 1);
|
||||
file_senders[i].active = true;
|
||||
file_senders[i].toxwin = self;
|
||||
file_senders[i].file = file_to_send;
|
||||
@ -220,7 +221,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
||||
tox_file_data_size(m, self->num), file_to_send);
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Sending file: '%s'", path);
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Sending file: '%s'", filename);
|
||||
|
||||
++num_active_file_senders;
|
||||
|
||||
|
@ -148,7 +148,7 @@ void close_all_file_senders(Tox *m)
|
||||
}
|
||||
}
|
||||
|
||||
static void send_file_data(ToxWindow *self, Tox *m, int i, int32_t friendnum, int filenum, const char *pathname)
|
||||
static void send_file_data(ToxWindow *self, Tox *m, int i, int32_t friendnum, int filenum, const char *filename)
|
||||
{
|
||||
FILE *fp = file_senders[i].file;
|
||||
|
||||
@ -175,15 +175,15 @@ static void send_file_data(ToxWindow *self, Tox *m, int i, int32_t friendnum, in
|
||||
|
||||
if (file_senders[i].piecelen == 0) {
|
||||
char msg[MAX_STR_SIZE];
|
||||
snprintf(msg, sizeof(msg), "File '%s' successfuly sent.", pathname);
|
||||
snprintf(msg, sizeof(msg), "File '%s' successfuly sent.", filename);
|
||||
close_file_sender(self, m, i, msg, TOX_FILECONTROL_FINISHED, filenum, friendnum);
|
||||
|
||||
if (self->active_box != -1)
|
||||
box_notify2(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2,
|
||||
self->active_box, "File '%s' successfuly sent!", pathname );
|
||||
self->active_box, "File '%s' successfuly sent!", filename );
|
||||
else
|
||||
box_notify(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box,
|
||||
self->name, "File '%s' successfuly sent!", pathname );
|
||||
self->name, "File '%s' successfuly sent!", filename );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -203,27 +203,27 @@ void do_file_senders(Tox *m)
|
||||
}
|
||||
|
||||
ToxWindow *self = file_senders[i].toxwin;
|
||||
char *pathname = file_senders[i].pathname;
|
||||
char *filename = file_senders[i].filename;
|
||||
int filenum = file_senders[i].filenum;
|
||||
int32_t friendnum = file_senders[i].friendnum;
|
||||
|
||||
/* If file transfer has timed out kill transfer and send kill control */
|
||||
if (timed_out(file_senders[i].timestamp, get_unix_time(), TIMEOUT_FILESENDER)) {
|
||||
char msg[MAX_STR_SIZE];
|
||||
snprintf(msg, sizeof(msg), "File transfer for '%s' timed out.", pathname);
|
||||
snprintf(msg, sizeof(msg), "File transfer for '%s' timed out.", filename);
|
||||
close_file_sender(self, m, i, msg, TOX_FILECONTROL_KILL, filenum, friendnum);
|
||||
sound_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, NULL);
|
||||
|
||||
if (self->active_box != -1)
|
||||
box_notify2(self, error, NT_NOFOCUS | NT_WNDALERT_2,
|
||||
self->active_box, "File transfer for '%s' failed!", pathname );
|
||||
self->active_box, "File transfer for '%s' failed!", filename );
|
||||
else
|
||||
box_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box,
|
||||
self->name, "File transfer for '%s' failed!", pathname );
|
||||
self->name, "File transfer for '%s' failed!", filename );
|
||||
continue;
|
||||
}
|
||||
|
||||
file_senders[i].queue_pos = num_active_file_senders - 1;
|
||||
send_file_data(self, m, i, friendnum, filenum, pathname);
|
||||
send_file_data(self, m, i, friendnum, filenum, filename);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ typedef struct {
|
||||
int filenum;
|
||||
char nextpiece[FILE_PIECE_SIZE];
|
||||
uint16_t piecelen;
|
||||
char pathname[MAX_STR_SIZE];
|
||||
char filename[MAX_STR_SIZE];
|
||||
uint64_t timestamp;
|
||||
uint64_t last_progress;
|
||||
double bps;
|
||||
|
Loading…
Reference in New Issue
Block a user