mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement buffer struct, cleanup buffer on page reload
This commit is contained in:
parent
9001b2521d
commit
8a16e9aa71
2 changed files with 40 additions and 7 deletions
|
|
@ -190,6 +190,9 @@ void Page::navigation_reload(
|
|||
socket__connection
|
||||
);
|
||||
|
||||
// Cleanup previous stream data
|
||||
buffer.clean();
|
||||
|
||||
// Update navigation history?
|
||||
if (ADD_HISTORY)
|
||||
{
|
||||
|
|
@ -349,10 +352,8 @@ void Page::navigation_reload(
|
|||
// Response
|
||||
// if (Socket::Connection::is_active(socket__connection)) // @TODO
|
||||
socket__connection->get_input_stream()->read_all_async( // | read_async @TODO
|
||||
buffer,
|
||||
sizeof(
|
||||
buffer
|
||||
) - 1, // @TODO
|
||||
buffer.data,
|
||||
buffer.capacity(),
|
||||
[this](const Glib::RefPtr<Gio::AsyncResult>&)
|
||||
{
|
||||
// Update
|
||||
|
|
@ -372,7 +373,7 @@ void Page::navigation_reload(
|
|||
// Parse meta
|
||||
Socket::Client::Gemini::Response::Status status; // @TODO make page global?
|
||||
Socket::Client::Gemini::Response::Match::meta(
|
||||
buffer,
|
||||
buffer.data,
|
||||
status,
|
||||
mime
|
||||
);
|
||||
|
|
@ -409,7 +410,7 @@ void Page::navigation_reload(
|
|||
// Use content driver
|
||||
pageContent->update(
|
||||
page::Content::TEXT_GEMINI,
|
||||
buffer,
|
||||
buffer.data,
|
||||
uri
|
||||
);
|
||||
|
||||
|
|
@ -644,6 +645,25 @@ sqlite3_int64 Page::Database::Session::add(
|
|||
|
||||
// Socket tools
|
||||
|
||||
/*
|
||||
* Buffer helpers
|
||||
*/
|
||||
unsigned long Page::Socket::Buffer::capacity()
|
||||
{
|
||||
return sizeof(
|
||||
data
|
||||
) - 1;
|
||||
}
|
||||
|
||||
void Page::Socket::Buffer::clean()
|
||||
{
|
||||
memset(
|
||||
data,
|
||||
0,
|
||||
DEFAULT_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Private helper to build socket client connections
|
||||
*
|
||||
|
|
|
|||
|
|
@ -84,6 +84,19 @@ namespace app::browser::main::tab
|
|||
*/
|
||||
struct Socket
|
||||
{
|
||||
struct Buffer
|
||||
{
|
||||
// Defaults
|
||||
static const size_t DEFAULT_SIZE = 0xfffff; // 1Mb
|
||||
|
||||
// Stream
|
||||
char data[DEFAULT_SIZE];
|
||||
|
||||
// Tools
|
||||
unsigned long capacity();
|
||||
void clean();
|
||||
};
|
||||
|
||||
class Client
|
||||
{
|
||||
private:
|
||||
|
|
@ -185,7 +198,7 @@ namespace app::browser::main::tab
|
|||
sqlite3 * database;
|
||||
|
||||
// Socket
|
||||
char buffer[0xfffff]; // 1Mb
|
||||
Socket::Buffer buffer;
|
||||
|
||||
// Shared socket connectors (for async operations)
|
||||
Glib::RefPtr<Gio::SocketClient> socket__client;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue