#ifndef MENU_NETCFG_H
#define MENU_NETCFG_H

#include <gui.h>
#include <gui/button.h>
#include <gui/checkbox.h>
#include <gui/container.h>
#include <gui/label.h>
#include <gui/line_edit.h>
#include <net.h>
#include <stdbool.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C"
{
#endif

struct menu_net_gui
{
    char device[32], address[32], port[sizeof "65535"];
    bool update_domain;
    struct gui_container cnt;
    struct gui_label type;
    struct gui_button type_btn;
    enum net_domain domain;

    union
    {
        struct gui_container cnt;

        struct menu_ipv4_gui
        {
            struct gui_container cnt, relay_cnt, announce_cnt;
            struct gui_button next_page_btn;
            struct gui_label address, port, relay, announce;
            struct gui_line_edit address_le, port_le, announce_le;
            struct gui_checkbox relay_ch, announce_ch;
        } ipv4;

        struct menu_serial_gui
        {
            struct gui_container cnt, hw_ctrl_cnt;
            struct gui_label device, speed, hw_ctrl;
            struct gui_button speed_btn;
            struct gui_line_edit device_le;
            struct gui_checkbox hw_ctrl_ch;
            size_t speed_i;
        } serial;
    } gui;
};

int menu_net_gui_init(struct menu_net_gui *m);
void menu_net_gui_update(struct menu_net_gui *m);
int menu_net_server(const struct menu_net_gui *m, union net_server *s);
int menu_net_connect(const struct menu_net_gui *m, union net_connect *c);

#ifdef __cplusplus
}
#endif

#endif /* MENU_NETCFG_H */
