mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
update socket connection
This commit is contained in:
parent
d8cf3c6d1f
commit
3c9b964a6b
2 changed files with 31 additions and 21 deletions
|
|
@ -248,7 +248,7 @@ void Page::navigation_reload(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset page data
|
// Reset page meta data
|
||||||
mime = MIME::UNDEFINED;
|
mime = MIME::UNDEFINED;
|
||||||
|
|
||||||
title = _("Update");
|
title = _("Update");
|
||||||
|
|
@ -272,23 +272,26 @@ void Page::navigation_reload(
|
||||||
if (g_uri_get_scheme(uri) == Glib::ustring("gemini"))
|
if (g_uri_get_scheme(uri) == Glib::ustring("gemini"))
|
||||||
{
|
{
|
||||||
// Create new socket connection
|
// Create new socket connection
|
||||||
GioSocketClient = Gio::SocketClient::create();
|
socket__client = Gio::SocketClient::create();
|
||||||
|
|
||||||
GioSocketClient->set_tls(
|
socket__client->set_tls(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
GioSocketClient->set_tls_validation_flags(
|
socket__client->set_tls_validation_flags(
|
||||||
Gio::TlsCertificateFlags::NO_FLAGS
|
Gio::TlsCertificateFlags::NO_FLAGS
|
||||||
);
|
);
|
||||||
|
|
||||||
GioSocketClient->set_timeout(
|
socket__client->set_timeout(
|
||||||
15 // @TODO
|
15 // @TODO
|
||||||
);
|
);
|
||||||
|
|
||||||
GioSocketClient->connect_to_uri_async(
|
socket__client->connect_to_uri_async(
|
||||||
pageNavigation->get_request_text(), 1965,
|
g_uri_to_string(
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
uri
|
||||||
|
),
|
||||||
|
1965, // default port @TODO
|
||||||
|
[this](const Glib::RefPtr<Gio::AsyncResult> & RESULT)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
title = _("Connect");
|
title = _("Connect");
|
||||||
|
|
@ -306,8 +309,8 @@ void Page::navigation_reload(
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GioSocketConnection = GioSocketClient->connect_to_uri_finish(
|
socket__connection = socket__client->connect_to_uri_finish(
|
||||||
result
|
RESULT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,14 +327,20 @@ void Page::navigation_reload(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection established, begin request
|
// Connection established, begin request
|
||||||
if (GioSocketConnection != nullptr)
|
if (socket__connection != nullptr)
|
||||||
{
|
{
|
||||||
const Glib::ustring request = pageNavigation->get_request_text() + "\r\n";
|
// Build gemini protocol request
|
||||||
|
const Glib::ustring SOCKET__REQUEST = Glib::ustring::sprintf(
|
||||||
|
"%s\r\n",
|
||||||
|
g_uri_to_string(
|
||||||
|
uri
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
GioSocketConnection->get_output_stream()->write_async(
|
socket__connection->get_output_stream()->write_async(
|
||||||
request.data(),
|
SOCKET__REQUEST.data(),
|
||||||
request.size(),
|
SOCKET__REQUEST.size(),
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult>&)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
title = _("Request");
|
title = _("Request");
|
||||||
|
|
@ -348,10 +357,10 @@ void Page::navigation_reload(
|
||||||
action__update->activate();
|
action__update->activate();
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
GioSocketConnection->get_input_stream()->read_all_async( // | read_async @TODO
|
socket__connection->get_input_stream()->read_all_async( // | read_async @TODO
|
||||||
buffer,
|
buffer,
|
||||||
sizeof(buffer) - 1,
|
sizeof(buffer) - 1,
|
||||||
[this](const Glib::RefPtr<Gio::AsyncResult> & result)
|
[this](const Glib::RefPtr<Gio::AsyncResult>&)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
title = _("Reading");
|
title = _("Reading");
|
||||||
|
|
@ -434,7 +443,7 @@ void Page::navigation_reload(
|
||||||
action__update->activate();
|
action__update->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
GioSocketConnection->close();
|
socket__connection->close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,9 @@ namespace app::browser::main::tab
|
||||||
// Socket
|
// Socket
|
||||||
char buffer[0xfffff]; // 1Mb
|
char buffer[0xfffff]; // 1Mb
|
||||||
|
|
||||||
Glib::RefPtr<Gio::SocketClient> GioSocketClient;
|
// Shared socket connectors (for async operations)
|
||||||
Glib::RefPtr<Gio::SocketConnection> GioSocketConnection;
|
Glib::RefPtr<Gio::SocketClient> socket__client;
|
||||||
|
Glib::RefPtr<Gio::SocketConnection> socket__connection;
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
page::Content * pageContent;
|
page::Content * pageContent;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue