ui: login process (without error processing)
This commit is contained in:
@@ -149,6 +149,7 @@ void app_draw_modal(app_t *app) {
|
||||
case S_ERR:
|
||||
case S_WAIT_SERVER:
|
||||
case S_N_D:
|
||||
case S_NEXT_ACTION:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../app.h"
|
||||
#include "../widget/dialogue.h"
|
||||
@@ -21,13 +22,20 @@ void init_login_credentials_modal_cb(callback_args_t *args) {
|
||||
memcpy(&d_args, args, sizeof(callback_args_t));
|
||||
d_args.app = NULL;
|
||||
d_args.resp_data = &response;
|
||||
input_t *in_ip = d->g_content->elements[0].element;
|
||||
input_t *in_port = d->g_content->elements[1].element;
|
||||
input_t *in_name = d->g_content->elements[0].element;
|
||||
input_t *in_pass = d->g_content->elements[1].element;
|
||||
dialogue_default_callback(&d_args);
|
||||
if (response > -1) {
|
||||
switch (response) {
|
||||
case 0:
|
||||
app->query_args->state = S_ASK_LOGIN_USER;
|
||||
app->params->uname = malloc(in_name->value_len + 1);
|
||||
app->params->pass = malloc(in_pass->value_len + 1);
|
||||
strncpy(app->params->uname, in_name->value, in_name->value_len);
|
||||
app->params->uname[in_name->value_len] = 0;
|
||||
strncpy(app->params->pass, in_pass->value, in_pass->value_len);
|
||||
app->params->pass[in_pass->value_len] = 0;
|
||||
write(app->params->sd, app->params->uname, in_name->value_len);
|
||||
app->query_args->state = S_WAIT_SERVER;
|
||||
destroy_dialogue(d);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -25,11 +25,11 @@ void server_message_modal_cb(callback_args_t *args) {
|
||||
switch (response) {
|
||||
case 0:
|
||||
destroy_dialogue(d);
|
||||
// TODO: macros
|
||||
/* TODO: macros */
|
||||
free(app->query_args->server_message.text);
|
||||
app->query_args->server_message.capacity = 0;
|
||||
app->query_args->server_message.size = 0;
|
||||
app->query_args->state = S_ASK_LOGIN_USER;
|
||||
app->query_args->state = S_NEXT_ACTION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +186,6 @@ int32_t draw_dialogue(dialogue_t *d) {
|
||||
x += 1; /* when uses box */
|
||||
y += 1; /* when uses box */
|
||||
|
||||
/* space for action block */
|
||||
|
||||
d->w.x = x;
|
||||
d->w.y = y;
|
||||
d->w.m_y = (d->p_coordinates->max_y - y) / 2;
|
||||
|
||||
Reference in New Issue
Block a user