diff --git a/src/app/backend/pcmanager.h b/src/app/backend/pcmanager.h index 59a5ba4c..2b8e8b5c 100644 --- a/src/app/backend/pcmanager.h +++ b/src/app/backend/pcmanager.h @@ -78,7 +78,7 @@ void pcmanager_unregister_listener(pcmanager_t *manager, const pcmanager_listene * @param userdata * @return */ -bool pcmanager_manual_add(pcmanager_t *manager, host_t *host, pcmanager_callback_t callback, void *userdata); +bool pcmanager_manual_add(pcmanager_t *manager, hostport_t *host, pcmanager_callback_t callback, void *userdata); /** * @brief Generates a PIN code, and start pairing process. diff --git a/src/app/backend/pcmanager/known_hosts.c b/src/app/backend/pcmanager/known_hosts.c index 634c4b92..c4651658 100644 --- a/src/app/backend/pcmanager/known_hosts.c +++ b/src/app/backend/pcmanager/known_hosts.c @@ -35,9 +35,9 @@ void pcmanager_load_known_hosts(pcmanager_t *manager) { bool selected_set = false; for (known_host_t *cur = hosts; cur; cur = cur->next) { const char *mac = cur->mac, *hostname = cur->hostname; - const host_t *address = cur->address; + const hostport_t *address = cur->address; char address_buf[256] = {0}; - host_to_string(address, address_buf, sizeof(address_buf)); + hostport_to_string(address, address_buf, sizeof(address_buf)); if (!mac || !hostname || !address) { commons_log_warn("PCManager", "Unknown host entry: mac=%s, hostname=%s, address=%s", mac, hostname, address_buf); @@ -48,8 +48,8 @@ void pcmanager_load_known_hosts(pcmanager_t *manager) { server->uuid = uuidstr_tostr(&cur->uuid); server->mac = mac; server->hostname = hostname; - server->serverInfo.address = strdup(host_get_hostname(address)); - server->extPort = host_get_port(address); + server->serverInfo.address = strdup(hostport_get_hostname(address)); + server->extPort = hostport_get_port(address); pclist_t *node = pclist_insert_known(manager, &cur->uuid, server); @@ -80,7 +80,7 @@ void pcmanager_save_known_hosts(pcmanager_t *manager) { continue; } const SERVER_DATA *server = cur->server; - host_t *address = host_new(server->serverInfo.address, server->extPort); + hostport_t *address = hostport_new(server->serverInfo.address, server->extPort); if (address == NULL) { continue; } @@ -90,9 +90,9 @@ void pcmanager_save_known_hosts(pcmanager_t *manager) { ini_write_string(fp, "hostname", server->hostname); char address_buf[260] = {0}; - host_to_string(address, address_buf, sizeof(address_buf)); + hostport_to_string(address, address_buf, sizeof(address_buf)); ini_write_string(fp, "address", address_buf); - host_free(address); + hostport_free(address); if (!selected_set && cur->selected) { ini_write_bool(fp, "selected", true); @@ -127,7 +127,7 @@ static int known_hosts_handle(known_host_t **list, const char *section, const ch } else if (INI_NAME_MATCH("hostname")) { host->hostname = SDL_strdup(value); } else if (INI_NAME_MATCH("address")) { - host->address = host_parse(value); + host->address = hostport_parse(value); } else if (INI_NAME_MATCH("selected")) { host->selected = INI_IS_TRUE(value); } else if (INI_NAME_MATCH("favorite")) { diff --git a/src/app/backend/pcmanager/known_hosts.h b/src/app/backend/pcmanager/known_hosts.h index 49868fcb..ed3b4224 100644 --- a/src/app/backend/pcmanager/known_hosts.h +++ b/src/app/backend/pcmanager/known_hosts.h @@ -26,7 +26,7 @@ typedef struct known_host_t { uuidstr_t uuid; char *mac; char *hostname; - host_t *address; + hostport_t *address; bool selected; appid_list_t *favs; appid_list_t *hidden; diff --git a/src/app/backend/pcmanager/pairing.c b/src/app/backend/pcmanager/pairing.c index 69e43fcd..ff627a5f 100644 --- a/src/app/backend/pcmanager/pairing.c +++ b/src/app/backend/pcmanager/pairing.c @@ -28,7 +28,7 @@ bool pcmanager_pair(pcmanager_t *manager, const uuidstr_t *uuid, char *pin, pcma return true; } -bool pcmanager_manual_add(pcmanager_t *manager, host_t *host, pcmanager_callback_t callback, void *userdata) { +bool pcmanager_manual_add(pcmanager_t *manager, hostport_t *host, pcmanager_callback_t callback, void *userdata) { if (host == NULL) { return false; } diff --git a/src/app/backend/pcmanager/worker/manual_add.c b/src/app/backend/pcmanager/worker/manual_add.c index 8a38b53d..23a185d1 100644 --- a/src/app/backend/pcmanager/worker/manual_add.c +++ b/src/app/backend/pcmanager/worker/manual_add.c @@ -10,6 +10,6 @@ int worker_add_by_host(worker_context_t *context) { } int updated_by_host(worker_context_t *context, bool force) { - const host_t *host = context->arg1; - return pcmanager_update_by_host(context, host_get_hostname(host), host_get_port(host), force); + const hostport_t *host = context->arg1; + return pcmanager_update_by_host(context, hostport_get_hostname(host), hostport_get_port(host), force); } diff --git a/src/app/ui/launcher/add.dialog.c b/src/app/ui/launcher/add.dialog.c index c6402ac5..9e4b69dd 100644 --- a/src/app/ui/launcher/add.dialog.c +++ b/src/app/ui/launcher/add.dialog.c @@ -99,7 +99,7 @@ static void dialog_cb(lv_event_t *event) { } uint16_t btn = lv_msgbox_get_active_btn(dialog); if (btn == 1) { - host_t *host = host_parse(lv_textarea_get_text(controller->input)); + hostport_t *host = hostport_parse(lv_textarea_get_text(controller->input)); if (!host) { return; } @@ -115,10 +115,10 @@ static void dialog_cb(lv_event_t *event) { static void input_changed_cb(lv_event_t *event) { add_dialog_controller_t *controller = lv_event_get_user_data(event); - host_t *host = host_parse(lv_textarea_get_text(controller->input)); + hostport_t *host = hostport_parse(lv_textarea_get_text(controller->input)); if (host) { lv_btnmatrix_clear_btn_ctrl(controller->btns, 1, LV_BTNMATRIX_CTRL_DISABLED); - host_free(host); + hostport_free(host); } else { lv_btnmatrix_set_btn_ctrl(controller->btns, 1, LV_BTNMATRIX_CTRL_DISABLED); } diff --git a/tests/app/backend/pcmanager/test_known_hosts.c b/tests/app/backend/pcmanager/test_known_hosts.c index 1fa773cf..36db4a0b 100644 --- a/tests/app/backend/pcmanager/test_known_hosts.c +++ b/tests/app/backend/pcmanager/test_known_hosts.c @@ -1,5 +1,6 @@ #include "unity.h" #include "backend/pcmanager/known_hosts.h" +#include "hostport.h" void setUp(void) { @@ -10,16 +11,13 @@ void tearDown(void) { } void test_parse() { - char buf[64]; known_host_t *hosts = known_hosts_parse(FIXTURES_PATH_PREFIX "hosts_read.ini"); - sockaddr_get_ip_str(hosts->address, buf, sizeof(buf)); - TEST_ASSERT_EQUAL_STRING("192.168.1.100", buf); - TEST_ASSERT_EQUAL(0, sockaddr_get_port(hosts->address)); + TEST_ASSERT_EQUAL_STRING("192.168.1.100", hostport_get_hostname(hosts->address)); + TEST_ASSERT_EQUAL(0, hostport_get_port(hosts->address)); known_host_t *next = hosts->next; - sockaddr_get_ip_str(next->address, buf, sizeof(buf)); - TEST_ASSERT_EQUAL_STRING("192.168.1.101", buf); - TEST_ASSERT_EQUAL(47985, sockaddr_get_port(next->address)); + TEST_ASSERT_EQUAL_STRING("192.168.1.101", hostport_get_hostname(next->address)); + TEST_ASSERT_EQUAL(47985, hostport_get_port(next->address)); known_hosts_free(hosts, known_hosts_node_free); } diff --git a/third_party/commons b/third_party/commons index 7415d2d8..f7ccc1dc 160000 --- a/third_party/commons +++ b/third_party/commons @@ -1 +1 @@ -Subproject commit 7415d2d81c50e64040d468c8ca2d1eaebfc135d9 +Subproject commit f7ccc1dc4d575cdd4e4e23b6ff5436bb9a53df36