+Cancel download [needs to test]

This commit is contained in:
2026-05-28 16:44:44 +03:00
parent ba9631a513
commit 8c87c46c46
8 changed files with 41 additions and 21 deletions
+4 -3
View File
@@ -1,12 +1,13 @@
# TODO:
## Current:
- [ ] Break line automatically in modal widgets
- [ ] Cancel upload/download
- [ ] Show download/upload progress in percentages
- [ ] File upload multiline description (window)
- [ ] Separate common structures in the common.h
- [ ] Sorting in the file list
- [ ] Cancel upload/download
- [ ] Break line automatically in modal widgets
- [ ] Show download/upload progress in percentages
- [ ] Resume download
- [x] Input: fix non-Latin letters
- [x] Get rid of unsigned integers
- [x] Check registration / enter server name again
+1 -1
View File
@@ -28,7 +28,7 @@ void app_draw_modal(app_t *app) {
case S_PRINT_SERVER_MESSAGE:
m_server_message_init(app);
break;
case S_FILE_DOWNLOAD:
case S_DOWNLOAD_FILE:
m_load_pr_init(app, false);
break;
case S_UPLOAD_FILE:
+1 -1
View File
@@ -101,7 +101,7 @@ int32_t ui_file_select(file_args_t *f_args, query_args_t *q_args, int32_t idx) {
return -2;
}
server_send_string(q_args, "file download [%s]\n", f_selected->name);
q_args->state = S_FILE_DOWNLOAD;
q_args->state = S_DOWNLOAD_FILE;
free(file_path);
return OK;
}
+1 -1
View File
@@ -42,7 +42,7 @@ enum state {
S_FILE_LIST,
S_WAIT_PASS,
/* S_FILE_SELECT, */
S_FILE_DOWNLOAD,
S_DOWNLOAD_FILE,
S_UPLOAD_PARAMS,
S_UPLOAD_FILE,
/* S_UPLOAD_FILE_SELECT, */
+22 -3
View File
@@ -1,25 +1,44 @@
#include "../server.h"
#include "alert.h"
#include "dialogue.h"
#include "group.h"
#include "utils.h"
#include "../windows/file_list.h"
#include <ncursesw/ncurses.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <widget.h>
void dwn_pr_modal_cb(w_cb_args_t *args) {
/* only cancel action */
int32_t key = *((int32_t *)args->data);
if (key != '\n') {
return;
}
app_t *app = args->app;
w_dialogue_t *d = &(app->modal);
/* TODO: forward actual file name */
bool response = w_bool_ask("Cancel file load", "Yes", "No", false,
"You're going to cancel download\n Are you sure?",
app->query_args->file->name);
if (app->query_args->state == S_UPLOAD_FILE) {
bool response = w_bool_ask("Cancel file upload", "Yes", "No", false,
"You're going to cancel upload\n Are you sure?");
if (response) {
app->query_args->file->signal = sig_cancel;
}
} else if (app->query_args->state == S_DOWNLOAD_FILE) {
w_ui_file_list_t *fui = (w_ui_file_list_t *)app->query_args->main_ui->ui;
bool response =
w_bool_ask("Cancel file download", "Yes", "No", false,
"You're going to cancel download\n Are you sure?");
server_send_string(app->query_args, "cancel\n");
FILE_CLEAN(app);
d->needs_destroy = true;
app->query_args->state = S_FILE_LIST;
server_send_string(app->query_args, "file list %d %d\n", fui->max_lines,
fui->current_page);
}
}
w_dialogue_t *m_load_pr_init(app_t *app, bool is_upload) {
+1 -8
View File
@@ -45,13 +45,6 @@ int32_t process_user_input(app_t *app, w_cb_args_t *d_args);
app_destroy(app, exit_code); \
}
#define FILE_CLEAN(app) \
if (app->query_args->file != NULL) { \
FREE_MLC(app->query_args->file->name); \
FREE_MLC(app->query_args->file->path); \
FREE_MLC(app->query_args->file); \
}
void query_loop(app_t *app) {
query_args_t *query_args = app->query_args;
fd_set readfds;
@@ -183,7 +176,7 @@ int process_query(app_t *app) {
case S_FILE_LIST:
file_list(file_args, query_args);
break;
case S_FILE_DOWNLOAD:
case S_DOWNLOAD_FILE:
file_download(file_args, query_args);
break;
case S_UPLOAD_REQUESTED:
+7
View File
@@ -9,4 +9,11 @@
free(arg); \
arg = NULL; \
}
#define FILE_CLEAN(app) \
if (app->query_args->file != NULL) { \
FREE_MLC(app->query_args->file->name); \
FREE_MLC(app->query_args->file->path); \
FREE_MLC(app->query_args->file); \
}
#endif
+2 -2
View File
@@ -60,7 +60,7 @@ static void decr_active_id(w_dialogue_t *d) {
}
static void case_callback(w_cb_args_t *args, w_cb_args_t *new_args) {
w_dialogue_t *d = (void *)args->element;
w_dialogue_t *d = args->element;
/* run callback function */
if (d->active_el->g_type == g_content) {
new_args->element = d->g_content;
@@ -74,7 +74,7 @@ static void case_callback(w_cb_args_t *args, w_cb_args_t *new_args) {
}
void w_dialogue_callback_default(w_cb_args_t *args) {
w_dialogue_t *d = (void *)args->element;
w_dialogue_t *d = args->element;
int32_t key = *((int32_t *)args->data);
w_cb_args_t new_args;
memcpy(&new_args, args, sizeof(w_cb_args_t));