ui: get rid of client files. changes pagination way in the file list.
This commit is contained in:
@@ -7,13 +7,13 @@ TODO:
|
||||
- [ ] Group elements as lists
|
||||
- [x] Process arrows
|
||||
- [x] Optimize modals re-drawings
|
||||
- [ ] Bug with file list on downloading files
|
||||
- [ ] Remember page numbers
|
||||
- [x] Bug with file list on downloading files
|
||||
- [x] Remember page numbers
|
||||
- [ ] "Server message" to notification
|
||||
- [ ] file list -> list template
|
||||
|
||||
UPLOAD:
|
||||
- [ ] Progress bar
|
||||
- [x] Progress bar
|
||||
- [x] Show notifications and messages from the server (universal way)
|
||||
use notification or something
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "file_processor.h"
|
||||
#include "main.h"
|
||||
#include "client.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int process_client_command(char *line, int l_len, query_args_t *q_args) {
|
||||
/* FILE LIST */
|
||||
if (!strncmp(line, "file list", sizeof("file list") - 1)) {
|
||||
write(q_args->sd, "file list", sizeof("file list") - 1);
|
||||
q_args->state = S_FILE_LIST;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FILE UPLOAD */
|
||||
if (!strncmp(line, "file upload", sizeof("file upload") - 1)) {
|
||||
if (!file_upload_request(line, q_args)) {
|
||||
q_args->state = S_UPLOAD_REQUESTED;
|
||||
} else {
|
||||
print_prompt(q_args->params);
|
||||
q_args->state = WAIT_CLIENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FILE DOWNLOAD */
|
||||
if (!strncmp(line, "file download", sizeof("file download") - 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EXIT */
|
||||
if (!strncmp(line, "exit", sizeof("exit") - 1)) {
|
||||
close(q_args->sd);
|
||||
printf("Bye!\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_prompt(params_t *params) {
|
||||
printf("%s> ", params->uname);
|
||||
fflush(stdout);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
#include "main.h"
|
||||
|
||||
int process_client_command(char *line, int l_len, query_args_t *q_args);
|
||||
void print_prompt(params_t *params);
|
||||
|
||||
#endif
|
||||
+7
-11
@@ -1,17 +1,13 @@
|
||||
client.o: src/client.c src/file_processor.h src/main.h src/types.h \
|
||||
src/ui/widget/file_list.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../main.h src/client.h
|
||||
connection.o: src/connection.c src/main.h src/types.h src/ui/app.h \
|
||||
src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h
|
||||
file_processor.o: src/file_processor.c src/client.h src/main.h \
|
||||
src/types.h src/file_processor.h src/ui/widget/file_list.h \
|
||||
src/ui/widget/../widget.h src/ui/widget/../../main.h src/query.h \
|
||||
src/ui/app.h src/ui/../common.h src/ui/widget.h src/ui/widget/dialogue.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h \
|
||||
file_processor.o: src/file_processor.c src/file_processor.h src/main.h \
|
||||
src/types.h src/ui/widget/file_list.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../main.h src/query.h src/ui/app.h src/ui/../common.h \
|
||||
src/ui/widget.h src/ui/widget/dialogue.h src/ui/widget/../../common.h \
|
||||
src/ui/widget/button.h src/ui/widget/../../main.h src/ui/widget/group.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/progress_bar.h
|
||||
fs.o: src/fs.c
|
||||
main.o: src/main.c src/connection.h src/main.h src/types.h src/ui/app.h \
|
||||
@@ -20,8 +16,8 @@ main.o: src/main.c src/connection.h src/main.h src/types.h src/ui/app.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h src/query.h \
|
||||
src/ui/widget.h src/ui/widget/file_list.h
|
||||
query.o: src/query.c src/client.h src/main.h src/types.h src/connection.h \
|
||||
src/ui/app.h src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
query.o: src/query.c src/connection.h src/main.h src/types.h src/ui/app.h \
|
||||
src/ui/../common.h src/ui/widget.h src/ui/../main.h \
|
||||
src/ui/widget/dialogue.h src/ui/widget/../widget.h \
|
||||
src/ui/widget/../../common.h src/ui/widget/button.h \
|
||||
src/ui/widget/../../main.h src/ui/widget/group.h src/file_processor.h \
|
||||
|
||||
+8
-23
@@ -14,7 +14,6 @@
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "file_processor.h"
|
||||
#include "main.h"
|
||||
#include "query.h"
|
||||
@@ -36,17 +35,21 @@ void file_list(file_args_t *f_args, query_args_t *q_args) {
|
||||
dialogue_t *d = (dialogue_t *)q_args->active_dialogue;
|
||||
fui->start = &(f_args->l_start);
|
||||
fui->current = &(f_args->l_current);
|
||||
bool list_end_reached = false;
|
||||
|
||||
if (qbuf_used == 0)
|
||||
qbuf[0] = 0;
|
||||
|
||||
if (!list_end_reached) {
|
||||
while ((qlen = query_extract_from_buf(q_args->buf, &(q_args->buf_used),
|
||||
&query))) {
|
||||
if (!strcmp("list_end\n", query)) {
|
||||
if (!strncmp(":END:", query, sizeof(":END:") - 1)) {
|
||||
sscanf(query, ":END: PAGE %u/%u COUNT: %u/%u\n", &fui->current_page,
|
||||
&fui->pages, &fui->current_count, &fui->full_count);
|
||||
idx = 1;
|
||||
list_end_reached = true;
|
||||
if (d != NULL && d->is_initiated) {
|
||||
d->needs_update = true;
|
||||
}
|
||||
draw_file_list(fui);
|
||||
q_args->state = S_FILE_SELECT;
|
||||
break;
|
||||
}
|
||||
strcat(qbuf, query);
|
||||
@@ -62,21 +65,6 @@ void file_list(file_args_t *f_args, query_args_t *q_args) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while ((qlen = query_extract_from_buf(q_args->buf, &(q_args->buf_used),
|
||||
&query))) {
|
||||
if (4 == sscanf(query, "=== PAGE %u/%u COUNT: %u/%u ===", &fui->current_page,
|
||||
&fui->pages, &fui->current_count, &fui->full_count)) {
|
||||
if (d != NULL && d->is_initiated) {
|
||||
d->needs_update = true;
|
||||
}
|
||||
draw_file_list(fui);
|
||||
q_args->state = S_FILE_SELECT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* file_select: old function, can be removed in the future */
|
||||
void file_select(file_args_t *f_args, query_args_t *q_args) {
|
||||
char *buf = q_args->buf;
|
||||
@@ -98,7 +86,6 @@ void file_select(file_args_t *f_args, query_args_t *q_args) {
|
||||
}
|
||||
|
||||
if (filenum == 0) {
|
||||
print_prompt(q_args->params);
|
||||
q_args->state = WAIT_CLIENT;
|
||||
return;
|
||||
}
|
||||
@@ -125,7 +112,6 @@ void file_select(file_args_t *f_args, query_args_t *q_args) {
|
||||
qlen = sprintf(send_buf, "error: %s\n", f_selected->name);
|
||||
write(q_args->sd, send_buf, qlen);
|
||||
perror(f_selected->name);
|
||||
print_prompt(q_args->params);
|
||||
q_args->state = WAIT_CLIENT;
|
||||
free(file_path);
|
||||
return;
|
||||
@@ -166,7 +152,6 @@ int32_t ui_file_select(file_args_t *f_args, query_args_t *q_args, int32_t idx) {
|
||||
qlen = sprintf(send_buf, "error: %s\n", f_selected->name);
|
||||
write(q_args->sd, send_buf, qlen);
|
||||
perror(f_selected->name);
|
||||
print_prompt(q_args->params);
|
||||
q_args->state = WAIT_CLIENT;
|
||||
free(file_path);
|
||||
return -2;
|
||||
|
||||
-10
@@ -16,7 +16,6 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "client.h"
|
||||
#include "connection.h"
|
||||
#include "file_processor.h"
|
||||
#include "main.h"
|
||||
@@ -233,20 +232,11 @@ static void wait_side(query_args_t *q_args) {
|
||||
int buf_used = q_args->buf_used;
|
||||
char *query = NULL;
|
||||
|
||||
if (q_args->state == WAIT_SERVER || q_args->state == WAIT_SERVER_INIT ||
|
||||
q_args->from_server || q_args->state == S_WAIT_SERVER) {
|
||||
while ((qlen = query_extract_from_buf(q_args->buf, &buf_used, &query))) {
|
||||
process_server_command(query, qlen, q_args);
|
||||
free(query);
|
||||
query = NULL;
|
||||
}
|
||||
} else if (q_args->state == WAIT_CLIENT) {
|
||||
while ((qlen = query_extract_from_buf(q_args->buf, &buf_used, &query))) {
|
||||
process_client_command(query, qlen, q_args);
|
||||
free(query);
|
||||
query = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_query_args(query_args_t *q_args, params_t *params) {
|
||||
|
||||
@@ -127,11 +127,11 @@ void draw_file_list(ui_file_list_t *fl_ui) {
|
||||
for (; p_y < sz_y_f; p_y++) {
|
||||
mvwprintw(parent_win, p_y, p_x, "%*s", sz_x - 1, "");
|
||||
}
|
||||
char p_info[24];
|
||||
char p_info[64];
|
||||
uint32_t p_len;
|
||||
p_x = 1;
|
||||
|
||||
sprintf(p_info, "page: %u/%u files: %u/%u%n", fl_ui->current_page,
|
||||
sprintf(p_info, "page: %u/%u files: %u left: %u%n", fl_ui->current_page,
|
||||
fl_ui->pages, fl_ui->current_count, fl_ui->full_count, &p_len);
|
||||
|
||||
uint32_t l_pad = (sz_x - p_len) / 2;
|
||||
|
||||
Reference in New Issue
Block a user