From 99c3c5b0e5c3680a0970c4e5e4bcd9c7f05e5983 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 17 Jan 2025 04:44:08 +0200 Subject: [PATCH] remove deprecated redirect chunk implementation --- .../browser/window/tab/item/page/client.rs | 4 +- .../window/tab/item/page/client/driver.rs | 14 +--- .../tab/item/page/client/driver/redirect.rs | 67 ------------------- .../item/page/client/driver/redirect/item.rs | 11 --- 4 files changed, 6 insertions(+), 90 deletions(-) delete mode 100644 src/app/browser/window/tab/item/page/client/driver/redirect.rs delete mode 100644 src/app/browser/window/tab/item/page/client/driver/redirect/item.rs diff --git a/src/app/browser/window/tab/item/page/client.rs b/src/app/browser/window/tab/item/page/client.rs index beed515d..7d50ad13 100644 --- a/src/app/browser/window/tab/item/page/client.rs +++ b/src/app/browser/window/tab/item/page/client.rs @@ -31,7 +31,9 @@ impl Client { pub fn init(profile: &Rc, callback: impl Fn(Status) + 'static) -> Self { Self { cancellable: Cell::new(Cancellable::new()), - driver: Driver::init(profile, move |status| callback(Status::Driver(status))), + driver: Driver::init(profile.clone(), move |status| { + callback(Status::Driver(status)) + }), status: Rc::new(RefCell::new(Status::Cancellable { time: now() })), // e.g. "ready to use" } } diff --git a/src/app/browser/window/tab/item/page/client/driver.rs b/src/app/browser/window/tab/item/page/client/driver.rs index 15844a8c..2c468724 100644 --- a/src/app/browser/window/tab/item/page/client/driver.rs +++ b/src/app/browser/window/tab/item/page/client/driver.rs @@ -2,11 +2,9 @@ //! by extending it features with new protocol, please make sub-module implementation mod gemini; -mod redirect; pub mod status; // Local dependencies -use redirect::Redirect; pub use status::Status; // Global dependencies @@ -19,10 +17,8 @@ use gtk::{ use std::rc::Rc; pub struct Driver { - /// Profile reference required for Gemini protocol auth (match request) + /// Profile reference required for Gemini protocol auth (match scope) profile: Rc, - /// Redirect resolver for different protocols - redirect: Rc, /// Supported clients /// * gemini driver should be initiated once (on page object init) /// to process all it connection features properly @@ -34,7 +30,7 @@ impl Driver { // Constructors /// Init new `Self` - pub fn init(profile: &Rc, callback: impl Fn(Status) + 'static) -> Self { + pub fn init(profile: Rc, callback: impl Fn(Status) + 'static) -> Self { // Init supported protocol libraries let gemini = Rc::new(ggemini::Client::new()); @@ -58,11 +54,7 @@ impl Driver { // other client listeners here.. // Done - Self { - profile: profile.clone(), - redirect: Rc::new(Redirect::new()), - gemini, - } + Self { profile, gemini } } // Actions diff --git a/src/app/browser/window/tab/item/page/client/driver/redirect.rs b/src/app/browser/window/tab/item/page/client/driver/redirect.rs deleted file mode 100644 index 1c7cbb2c..00000000 --- a/src/app/browser/window/tab/item/page/client/driver/redirect.rs +++ /dev/null @@ -1,67 +0,0 @@ -mod item; -use item::Item; - -use gtk::glib::Uri; -use std::cell::{Cell, RefCell}; - -/// Global limit to prevent infinitive redirection issues -/// * defined value is globally applicable to ALL drivers -/// * every driver implement its own value, according to protocol specification -/// * the `Client` will forcefully break redirection loop when iteration reach this value -pub const LIMIT: usize = 10; // @TODO make optional - -pub struct Redirect { - chain: RefCell>, -} - -impl Default for Redirect { - fn default() -> Self { - Self::new() - } -} - -impl Redirect { - // Constructors - - /// Create new `Self` - pub fn new() -> Self { - Self { - chain: RefCell::new(Vec::new()), - } - } - - // Actions - - /// Register new redirect in chain - pub fn add(&self, request: Uri, referrer: Option, is_foreground: bool) -> &Self { - self.chain.borrow_mut().push(Item { - request, - referrer, - is_foreground, - is_processed: Cell::new(false), - }); - self - } - - /// Clear redirect chain - pub fn clear(&self) { - self.chain.borrow_mut().clear() - } - - // Getters - - /// Get total redirects count in chain - pub fn count(&self) -> usize { - self.chain.borrow().len() + 1 - } - - /// Get last redirection `Item` copy - pub fn last(&self) -> Option { - if let Some(redirect) = self.chain.borrow().last() { - if !redirect.is_processed.replace(true) { - return Some(redirect.clone()); - } - } - None - } -} diff --git a/src/app/browser/window/tab/item/page/client/driver/redirect/item.rs b/src/app/browser/window/tab/item/page/client/driver/redirect/item.rs deleted file mode 100644 index af34cfc6..00000000 --- a/src/app/browser/window/tab/item/page/client/driver/redirect/item.rs +++ /dev/null @@ -1,11 +0,0 @@ -use gtk::glib::Uri; -use std::cell::Cell; - -/// Single redirect `Item` -#[derive(Clone)] -pub struct Item { - pub is_foreground: bool, - pub is_processed: Cell, - pub referrer: Option, - pub request: Uri, -}