1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 22:43:26 +01:00

don't show full path when sending files

This commit is contained in:
Jfreegman 2014-08-03 15:12:55 -04:00
parent c9e4246ac5
commit 79372cc80d
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
4 changed files with 15 additions and 14 deletions

View File

@ -373,7 +373,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec
break; break;
} }
filename = file_senders[i].pathname; filename = file_senders[i].filename;
} }
switch (control_type) { switch (control_type) {

View File

@ -196,7 +196,8 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
char filename[MAX_STR_SIZE] = {0}; char filename[MAX_STR_SIZE] = {0};
get_file_name(filename, sizeof(filename), path); 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) { if (filenum == -1) {
errmsg = "Error sending file."; 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) { for (i = 0; i < MAX_FILES; ++i) {
if (!file_senders[i].active) { if (!file_senders[i].active) {
file_senders[i].queue_pos = num_active_file_senders; 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].active = true;
file_senders[i].toxwin = self; file_senders[i].toxwin = self;
file_senders[i].file = file_to_send; 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, file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
tox_file_data_size(m, self->num), file_to_send); 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; ++num_active_file_senders;

View File

@ -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; 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) { if (file_senders[i].piecelen == 0) {
char msg[MAX_STR_SIZE]; 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); close_file_sender(self, m, i, msg, TOX_FILECONTROL_FINISHED, filenum, friendnum);
if (self->active_box != -1) if (self->active_box != -1)
box_notify2(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, 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 else
box_notify(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box, 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; return;
} }
} }
@ -203,27 +203,27 @@ void do_file_senders(Tox *m)
} }
ToxWindow *self = file_senders[i].toxwin; ToxWindow *self = file_senders[i].toxwin;
char *pathname = file_senders[i].pathname; char *filename = file_senders[i].filename;
int filenum = file_senders[i].filenum; int filenum = file_senders[i].filenum;
int32_t friendnum = file_senders[i].friendnum; int32_t friendnum = file_senders[i].friendnum;
/* If file transfer has timed out kill transfer and send kill control */ /* If file transfer has timed out kill transfer and send kill control */
if (timed_out(file_senders[i].timestamp, get_unix_time(), TIMEOUT_FILESENDER)) { if (timed_out(file_senders[i].timestamp, get_unix_time(), TIMEOUT_FILESENDER)) {
char msg[MAX_STR_SIZE]; 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); close_file_sender(self, m, i, msg, TOX_FILECONTROL_KILL, filenum, friendnum);
sound_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, NULL); sound_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, NULL);
if (self->active_box != -1) if (self->active_box != -1)
box_notify2(self, error, NT_NOFOCUS | NT_WNDALERT_2, 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 else
box_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box, 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; continue;
} }
file_senders[i].queue_pos = num_active_file_senders - 1; 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);
} }
} }

View File

@ -39,7 +39,7 @@ typedef struct {
int filenum; int filenum;
char nextpiece[FILE_PIECE_SIZE]; char nextpiece[FILE_PIECE_SIZE];
uint16_t piecelen; uint16_t piecelen;
char pathname[MAX_STR_SIZE]; char filename[MAX_STR_SIZE];
uint64_t timestamp; uint64_t timestamp;
uint64_t last_progress; uint64_t last_progress;
double bps; double bps;